Absolute beginner

Matej Nanut matejnanut at gmail.com
Fri Jan 13 14:05:19 PST 2012


While we're at it: what's the best way to parse in a formatted manner?
For example, if I want to get 5 hexadecimal digits converted into an
uint? And I want to simultaneously advance the string?

"sscanf" seems fiddly and unsafe.

On 13 January 2012 22:56, bearophile <bearophileHUGS at lycos.com> wrote:
> Timon Gehr:
>
>> readln() includes the trailing newline character in the resulting
>> string. You can use std.string.strip to remove leading and trailing
>> whitespace:
>
> Time ago I have asked Andrei to modify the to!int conversion to work as Python, ignoring leading and trailing whitespace:
>
>>>> s = "123\n"
>>>> int(s)
> 123
>
> But he didn't change it. I don't think people use parse at their first try.
>
> Bye,
> bearophile


More information about the Digitalmars-d-learn mailing list