digitalmars.D.learn - din.readf("%s", &floattype) should work?
- Michael P. (8/8) Jan 29 2010 Is din.readf (from std.cstream in Phobos) able to read floats when using...
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (7/16) Jan 29 2010 Reading Stream.vreadf in dmd/src/phobos/std/stream.d, I see that %s
Is din.readf (from std.cstream in Phobos) able to read floats when using %s as the format specifier? When I used this: din.readf( "%s", &somedouble ); somedouble will still be nan after receiving input from the user. But when I use: din.readf( "%f", &somedouble ); everything goes as planned. Is this to be expected?
Jan 29 2010
Michael P. wrote:Is din.readf (from std.cstream in Phobos) able to read floats when using %s as the format specifier? When I used this: din.readf( "%s", &somedouble ); somedouble will still be nan after receiving input from the user. But when I use: din.readf( "%f", &somedouble ); everything goes as planned. Is this to be expected?Reading Stream.vreadf in dmd/src/phobos/std/stream.d, I see that %s means "string". It means "string" for output as well. Objects of any type can be converted to string and outputted that way. The member function toString is used for user defined types. Ali
Jan 29 2010