Conversion error.

Adam D. Ruppe destructionator at gmail.com
Thu Jan 28 01:09:52 UTC 2021


On Thursday, 28 January 2021 at 01:01:36 UTC, Ruby The Roobster 
wrote:
>     readf("%d",x);

This is why I hate readf, it is sensitive to litte things.

If you put a space in that string I think it will fix it. What 
happens here is it reads the float, then leaves the buffer at the 
\n from when the user pressed enter. So when it comes around it 
complains about that unexpected character.

So try readf(" %d") or readf("%d\n") or something like that.

OR just use `readln().strip().to!int` that kind fo thing.


More information about the Digitalmars-d-learn mailing list