digitalmars.D - std.stream.stdin.read bug ?
- Asaf Karagila (20/20) Oct 09 2004 004020BE |> /8D45 FC /LEA EAX, [LOCAL.1]
- Ben Hinkle (6/30) Oct 09 2004 I'm not sure why read() is behaving like it is, but I would try using
- Asaf Karagila (6/37) Oct 09 2004 input is UINT, i forgot to mention that.. sorry..
- Ben Hinkle (10/50) Oct 09 2004 If you are typing at the console you need to use scanf. For example,
- Asaf Karagila (5/61) Oct 09 2004 thanks, its working now..
004020BE |> /8D45 FC /LEA EAX, [LOCAL.1] 004020C1 |. |50 |PUSH EAX 004020C2 |. |A1 70BB4100 |MOV EAX, DWORD PTR DS:[41BB70] 004020C7 |. |8B08 |MOV ECX, DWORD PTR DS:[EAX] 004020C9 |. |FF51 38 |CALL NEAR DWORD PTR DS:[ECX+38] 004020CC |. |837D FC 02 |CMP [LOCAL.1], 2 004020D0 |. |76 05 |JBE SHORT hello.004020D7 004020D2 |. |8B45 FC |MOV EAX, [LOCAL.1] 004020D5 |. |C9 |LEAVE 004020D6 |. |C3 |RET is compiled from this code: std.stream.stdin.read(input); if (input > 2) return input; the LOCAL.1 address is pointed to the read(), but is not changing to the input value. instead i get '168636723' for every input i give in.. anyone experienced with it ? is it a compiler bug or my problem ? Cheers, Asaf
Oct 09 2004
Asaf Karagila wrote:004020BE |> /8D45 FC /LEA EAX, [LOCAL.1] 004020C1 |. |50 |PUSH EAX 004020C2 |. |A1 70BB4100 |MOV EAX, DWORD PTR DS:[41BB70] 004020C7 |. |8B08 |MOV ECX, DWORD PTR DS:[EAX] 004020C9 |. |FF51 38 |CALL NEAR DWORD PTR DS:[ECX+38] 004020CC |. |837D FC 02 |CMP [LOCAL.1], 2 004020D0 |. |76 05 |JBE SHORT hello.004020D7 004020D2 |. |8B45 FC |MOV EAX, [LOCAL.1] 004020D5 |. |C9 |LEAVE 004020D6 |. |C3 |RET is compiled from this code: std.stream.stdin.read(input); if (input > 2) return input; the LOCAL.1 address is pointed to the read(), but is not changing to the input value. instead i get '168636723' for every input i give in.. anyone experienced with it ? is it a compiler bug or my problem ? Cheers, AsafI'm not sure why read() is behaving like it is, but I would try using scanf() instead. read() is for binary input. scanf() is for text input. Are you typing in values from the console or are you piping something into stdin? -Ben
Oct 09 2004
"Ben Hinkle" <bhinkle4 juno.com> wrote in message news:ck8or5$k9t$1 digitaldaemon.com...Asaf Karagila wrote:input is UINT, i forgot to mention that.. sorry.. and i am typing into the console. Cheers, Asaf004020BE |> /8D45 FC /LEA EAX, [LOCAL.1] 004020C1 |. |50 |PUSH EAX 004020C2 |. |A1 70BB4100 |MOV EAX, DWORD PTR DS:[41BB70] 004020C7 |. |8B08 |MOV ECX, DWORD PTR DS:[EAX] 004020C9 |. |FF51 38 |CALL NEAR DWORD PTR DS:[ECX+38] 004020CC |. |837D FC 02 |CMP [LOCAL.1], 2 004020D0 |. |76 05 |JBE SHORT hello.004020D7 004020D2 |. |8B45 FC |MOV EAX, [LOCAL.1] 004020D5 |. |C9 |LEAVE 004020D6 |. |C3 |RET is compiled from this code: std.stream.stdin.read(input); if (input > 2) return input; the LOCAL.1 address is pointed to the read(), but is not changing to the input value. instead i get '168636723' for every input i give in.. anyone experienced with it ? is it a compiler bug or my problem ? Cheers, AsafI'm not sure why read() is behaving like it is, but I would try using scanf() instead. read() is for binary input. scanf() is for text input. Are you typing in values from the console or are you piping something into stdin? -Ben
Oct 09 2004
On Sat, 9 Oct 2004 15:31:38 +0200, "Asaf Karagila" <kas1 netvision.net.il> wrote:"Ben Hinkle" <bhinkle4 juno.com> wrote in message news:ck8or5$k9t$1 digitaldaemon.com...If you are typing at the console you need to use scanf. For example, import std.stream; int main() { uint input; stdin.scanf("%u",&input); stdout.writefln("you typed ", input); return 0; }Asaf Karagila wrote:input is UINT, i forgot to mention that.. sorry.. and i am typing into the console. Cheers, Asaf004020BE |> /8D45 FC /LEA EAX, [LOCAL.1] 004020C1 |. |50 |PUSH EAX 004020C2 |. |A1 70BB4100 |MOV EAX, DWORD PTR DS:[41BB70] 004020C7 |. |8B08 |MOV ECX, DWORD PTR DS:[EAX] 004020C9 |. |FF51 38 |CALL NEAR DWORD PTR DS:[ECX+38] 004020CC |. |837D FC 02 |CMP [LOCAL.1], 2 004020D0 |. |76 05 |JBE SHORT hello.004020D7 004020D2 |. |8B45 FC |MOV EAX, [LOCAL.1] 004020D5 |. |C9 |LEAVE 004020D6 |. |C3 |RET is compiled from this code: std.stream.stdin.read(input); if (input > 2) return input; the LOCAL.1 address is pointed to the read(), but is not changing to the input value. instead i get '168636723' for every input i give in.. anyone experienced with it ? is it a compiler bug or my problem ? Cheers, AsafI'm not sure why read() is behaving like it is, but I would try using scanf() instead. read() is for binary input. scanf() is for text input. Are you typing in values from the console or are you piping something into stdin? -Ben
Oct 09 2004
"Ben Hinkle" <bhinkle4 juno.com> wrote in message news:gq1gm0l9tv2pvn05tp27m8rs5ekomhu3fu 4ax.com...On Sat, 9 Oct 2004 15:31:38 +0200, "Asaf Karagila" <kas1 netvision.net.il> wrote:thanks, its working now.. Cheers, Asaf"Ben Hinkle" <bhinkle4 juno.com> wrote in message news:ck8or5$k9t$1 digitaldaemon.com...If you are typing at the console you need to use scanf. For example, import std.stream; int main() { uint input; stdin.scanf("%u",&input); stdout.writefln("you typed ", input); return 0; }Asaf Karagila wrote:input is UINT, i forgot to mention that.. sorry.. and i am typing into the console. Cheers, Asaf004020BE |> /8D45 FC /LEA EAX, [LOCAL.1] 004020C1 |. |50 |PUSH EAX 004020C2 |. |A1 70BB4100 |MOV EAX, DWORD PTR DS:[41BB70] 004020C7 |. |8B08 |MOV ECX, DWORD PTR DS:[EAX] 004020C9 |. |FF51 38 |CALL NEAR DWORD PTR DS:[ECX+38] 004020CC |. |837D FC 02 |CMP [LOCAL.1], 2 004020D0 |. |76 05 |JBE SHORT hello.004020D7 004020D2 |. |8B45 FC |MOV EAX, [LOCAL.1] 004020D5 |. |C9 |LEAVE 004020D6 |. |C3 |RET is compiled from this code: std.stream.stdin.read(input); if (input > 2) return input; the LOCAL.1 address is pointed to the read(), but is not changing to the input value. instead i get '168636723' for every input i give in.. anyone experienced with it ? is it a compiler bug or my problem ? Cheers, AsafI'm not sure why read() is behaving like it is, but I would try using scanf() instead. read() is for binary input. scanf() is for text input. Are you typing in values from the console or are you piping something into stdin? -Ben
Oct 09 2004