Why doesn't this piece of code work?
Ali Çehreli
acehreli at yahoo.com
Mon May 16 22:36:54 UTC 2022
On 5/16/22 15:25, kdevel wrote:
> string a;
> a = readln();
> writeln(a);
> consumes that newline from your first input resulting in variable a
> containing the empty string ending with a newline.
Great catch! I should put this combination in my chapter.
> I am not sure, why %s fits here. I would have expected a %d format for
> parsing the integer.
I learned to read %s as "whatever the type of the argument is" (not
"string").
Ali
More information about the Digitalmars-d-learn
mailing list