taking a character out of a string
Michael P.
baseball.mjp at gmail.com
Mon Aug 18 17:09:04 PDT 2008
bearophile Wrote:
> 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
Any reason why you put:
import std.stdio: putr = writefln;
import std.string: removechars;
instead of just:
import std.stdio;
import std.string;
???
More information about the Digitalmars-d-learn
mailing list