digitalmars.D.learn - Problem with simple Formatted Input example.
- Venkat Akkineni (15/15) Feb 07 2015 This simple program seems to just hang. I am probably missing
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (10/18) Feb 07 2015 My earlier understanding was that readf was reading till the end of the
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (5/8) Feb 07 2015 OK, that is related to the '\n' character that you have in the format
- Venkat Akkineni (6/15) Feb 07 2015 Thankyou, I think it was encoded to be some other character
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);
writeln(firstName);
}
Thankyou
Venkat
Feb 07 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
Feb 07 2015
On 02/07/2015 04:42 PM, Ali Çehreli wrote:> readf(" %s\n", &firstName);I see that readf reads the first line of entry *after* I press two Enters on the console.OK, that is related to the '\n' character that you have in the format string. Also, repeating the space characters has no effect as a single space means "zero or more white space" anyway. Ali
Feb 07 2015
On Sunday, 8 February 2015 at 00:47:46 UTC, Ali Çehreli wrote:On 02/07/2015 04:42 PM, Ali Çehreli wrote:Thankyou, I think it was encoded to be some other character instead of a space. Once I removed the space and re-added it to the string, things seem to work. I am reading your book. It is a great book for newbies. Thanks a lot for the effort.> readf(" %s\n", &firstName);I see that readf reads the first line of entry *after* I press two Enters on the console.OK, that is related to the '\n' character that you have in the format string. Also, repeating the space characters has no effect as a single space means "zero or more white space" anyway. Ali
Feb 07 2015








"Venkat Akkineni" <venkatram.akkineni gmail.com>