digitalmars.D.learn - A possible readf int bug
I'm trying to read from stdin and then print an integer value.
This is how my code looks like:
```d
import std.stdio;
import std.conv;
import std.string;
void main()
{
writeln("Input your variant (1 - 10):");
int key;
//readf(" %d", &key);
//readf!" %d"(key);
key = readln.strip.to!int;
writefln("Your variant is: %d", key);
}
```
The problem is that the programme doesn't work if I try to use
one of the commented readf functions. It doesn't print the last
phrase. There is no error message. It just waits for nothing
apparently. It works with the stip.to!int line, so the problem
must be with readf.
I'm kind of new to this language and I don't have much experience
with programming in general, so I have no way to know if it's
just me being dumb or I've accidently found a bug.
I use DMD32 D Compiler v2.097.0-dirty
Jun 27 2021
On Sunday, 27 June 2021 at 19:50:09 UTC, Matilda wrote:
I'm trying to read from stdin and then print an integer value.
This is how my code looks like:
```d
import std.stdio;
import std.conv;
import std.string;
void main()
{
writeln("Input your variant (1 - 10):");
int key;
//readf(" %d", &key);
//readf!" %d"(key);
key = readln.strip.to!int;
writefln("Your variant is: %d", key);
}
```
The problem is that the programme doesn't work if I try to use
one of the commented readf functions. It doesn't print the last
phrase. There is no error message. It just waits for nothing
apparently. It works with the stip.to!int line, so the problem
must be with readf.
I'm kind of new to this language and I don't have much
experience with programming in general, so I have no way to
know if it's just me being dumb or I've accidently found a bug.
I use DMD32 D Compiler v2.097.0-dirty
This works with either readf line for me on v2.097.0.
Try stracing your program.
Jun 27 2021
On Sunday, 27 June 2021 at 20:12:09 UTC, jfondren wrote:On Sunday, 27 June 2021 at 19:50:09 UTC, Matilda wrote:Okay, thank you. I'll try it out.[...]This works with either readf line for me on v2.097.0. Try stracing your program.
Jun 27 2021








Matilda <marusiavrn gmail.com>