digitalmars.D.learn - Why does this not work?
- TheDGuy (3/3) Jan 01 2016 writeln("Which number should i guess?");
- Tobi G. (6/9) Jan 01 2016 The solution is that readln() returns a string that also contains
- Tobi G. (2/7) Jan 01 2016 Sorry my bad english.. i wrote solution but meant problem
- TheDGuy (3/12) Jan 01 2016 Thank you very much! That helped me alot. It is kind of hard if
- bachmeier (3/16) Jan 01 2016 I've battled with a few times, not having any idea what was going
- Adam D. Ruppe (6/9) Jan 01 2016 This is one of the most frequently asked questions by new users..
- TheDGuy (4/14) Jan 01 2016 If i had known that blog existed. I think your example at the end
- Adam D. Ruppe (6/9) Jan 01 2016 I just wrote that example in response to this thread :P (the
- bachmeier (6/16) Jan 01 2016 If the user is reading the docs completely, yes, it is clear. It
- israel (4/7) Jan 01 2016 You fell for the C# syntax like me...
writeln("Which number should i guess?"); string input = readln(); int i = to!int(input);
Jan 01 2016
On Friday, 1 January 2016 at 14:00:41 UTC, TheDGuy wrote:writeln("Which number should i guess?"); string input = readln(); int i = to!int(input);The solution is that readln() returns a string that also contains the newline this can be solved by easily stripping the newline off import std.string; int i = to!int(input.strip);
Jan 01 2016
On Friday, 1 January 2016 at 14:20:26 UTC, Tobi G. wrote:The solution is that readln() returns a string that also contains the newline this can be solved by easily stripping the newline off import std.string; int i = to!int(input.strip);Sorry my bad english.. i wrote solution but meant problem
Jan 01 2016
On Friday, 1 January 2016 at 14:29:34 UTC, Tobi G. wrote:On Friday, 1 January 2016 at 14:20:26 UTC, Tobi G. wrote:Thank you very much! That helped me alot. It is kind of hard if you don't have the background knowledge...The solution is that readln() returns a string that also contains the newline this can be solved by easily stripping the newline off import std.string; int i = to!int(input.strip);Sorry my bad english.. i wrote solution but meant problem
Jan 01 2016
On Friday, 1 January 2016 at 14:47:20 UTC, TheDGuy wrote:On Friday, 1 January 2016 at 14:29:34 UTC, Tobi G. wrote:I've battled with a few times, not having any idea what was going on. I now almost automatically use strip when it's not working.On Friday, 1 January 2016 at 14:20:26 UTC, Tobi G. wrote:Thank you very much! That helped me alot. It is kind of hard if you don't have the background knowledge...The solution is that readln() returns a string that also contains the newline this can be solved by easily stripping the newline off import std.string; int i = to!int(input.strip);Sorry my bad english.. i wrote solution but meant problem
Jan 01 2016
On Friday, 1 January 2016 at 15:06:53 UTC, bachmeier wrote:I've battled with a few times, not having any idea what was going on. I now almost automatically use strip when it's not working.This is one of the most frequently asked questions by new users.. I added a tip to my new docs: http://dpldocs.info/experimental-docs/std.stdio.readln.html If you were looking at that for the first time, would you notice it? If no, I can see about moving it or rewording it or something.
Jan 01 2016
On Friday, 1 January 2016 at 15:16:36 UTC, Adam D. Ruppe wrote:On Friday, 1 January 2016 at 15:06:53 UTC, bachmeier wrote:If i had known that blog existed. I think your example at the end of the page explains the problem really well. Thanks!I've battled with a few times, not having any idea what was going on. I now almost automatically use strip when it's not working.This is one of the most frequently asked questions by new users.. I added a tip to my new docs: http://dpldocs.info/experimental-docs/std.stdio.readln.html If you were looking at that for the first time, would you notice it? If no, I can see about moving it or rewording it or something.
Jan 01 2016
On Friday, 1 January 2016 at 17:00:23 UTC, TheDGuy wrote:If i had known that blog existed. I think your example at the end of the page explains the problem really well. Thanks!I just wrote that example in response to this thread :P (the overall thing there is something i started last week to reorganize the official docs to be easier to read and edit) But it is a common enough question that it should just be in the documentation.
Jan 01 2016
On Friday, 1 January 2016 at 15:16:36 UTC, Adam D. Ruppe wrote:On Friday, 1 January 2016 at 15:06:53 UTC, bachmeier wrote:If the user is reading the docs completely, yes, it is clear. It would probably be better to put it in its own section, because a user might not expect to find an explanation of a pitfall in there, and because it makes it easy to find when you're looking the second or third time.I've battled with a few times, not having any idea what was going on. I now almost automatically use strip when it's not working.This is one of the most frequently asked questions by new users.. I added a tip to my new docs: http://dpldocs.info/experimental-docs/std.stdio.readln.html If you were looking at that for the first time, would you notice it? If no, I can see about moving it or rewording it or something.
Jan 01 2016
On Friday, 1 January 2016 at 14:00:41 UTC, TheDGuy wrote:writeln("Which number should i guess?"); string input = readln(); int i = to!int(input);According to Ahli. You have to use the old C way of doing it with readf.
Jan 01 2016