Hi! I'm new at programming, just discovered D and I'm loving it so far!
I'm learning the basics, so please forgive my noob mistakes and questions (as well as my Engrish...).
I'm trying to make this program print both numbers entered by the user, it works with the first number (num):
import std.stdio;
void main(){
struct Fraction
{
int num;
int den;
}
Fraction f1;
write("Num: ");
readf("%s", &f1.num);
writef("Num is: %s", f1.num);
}
But when I try the same with the second one, I get an error after entering the first number:
import std.stdio;
void main(){
struct Fraction
{
int num;
int den;
}
Fraction f1;
write("Num: ");
readf("%s", &f1.num);
write("Den: ");
readf("%s", &f1.den);
writef("Num is: %s", f1.num);
writef("Den is: %s", f1.den);
}
std.conv.ConvException@C:\D\dmd2\windows\bin....\src\phobos\std\conv.d(2526): Unexpected '\n' when converting from type LockingTextReader to type int
0x00C80D74
0x00C80A77
0x00C80559
0x00C8047D
0x00C7FEDB
0x00C7FE4F
0x00C71045
0x00C8CE23
0x00C8CD8F
0x00C8CC0C
0x00C81D6C
0x00C7107F
0x75ADFA29 in BaseThreadInitThunk
0x77957A9E in RtlGetAppContainerNamedObjectPath
0x77957A6E in RtlGetAppContainerNamedObjectPath
May someone tell me what am I doing wrong? Thank you in advance! :)