Problem with simple Formatted Input example.

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Feb 7 16:42:56 PST 2015


On 02/07/2015 04:29 PM, Venkat Akkineni wrote:> This simple program 
seems to just hang. I am probably missing something.
 > Any help is appreciated. I am using Linux with DMD. Program compiles
 > fine, but when enter a string & press enter, the programs seems to wait
 > forever without returning.
 >
 >
 > import std.stdio;
 >
 > void main()
 > {
 >
 >      string firstName;
 >      readf("    %s\n", &firstName);

My earlier understanding was that readf was reading till the end of the 
input. So, you will see that it will terminate when you press Ctrl-D at 
the console. I explain that understanding here:

   http://ddili.org/ders/d.en/strings.html#ix_strings.readln

However, when I tried your code again with dmd git head, I see that 
readf reads the first line of entry *after* I press two Enters on the 
console.

Ali



More information about the Digitalmars-d-learn mailing list