Unexpected ' ' when converting from type string to type int

Michael S via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 29 17:49:37 PST 2015


On Wednesday, 30 December 2015 at 01:38:32 UTC, Adam D. Ruppe 
wrote:
> On Wednesday, 30 December 2015 at 01:36:56 UTC, Michael S wrote:
>>     auto matrix_size = readln;
>
> Change that to
>
> auto matrix_size = readln.strip;
>
>
> and you should be in business. readln() returns any leading 
> spaces and the newline character at the end of the line too, 
> which is why to is throwing.
>
> The .strip function will trim that whitespace off.

Wow thank you Adam. I didn't expect to have a reply so quickly, 
especially a slam dunk like that one. It works perfectly now!


More information about the Digitalmars-d-learn mailing list