taking a character out of a string

bearophile bearophileHUGS at lycos.com
Mon Aug 18 16:32:04 PDT 2008


Michael P.:
> read in 2 phrases, then use 2 foreach loops to check for spaces and
> remove them.

No need to use foreach loops, learn to use string functions:

import std.stdio: putr = writefln;
import std.string: removechars;

void main() {
    string txt = "This is is a string".dup;
    putr(txt.removechars(" "));
}

Output:
Thisisisastring

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list