I've never noticed std.conv.parse takes a radix argument, silly me.
And will take
a look at readf from std.stream, definitely.
Thanks!
On 14 January 2012 01:20, Justin Whear wrote:
> On Fri, 13 Jan 2012 23:05:19 +0100, Matej Nanut wrote:
>
>> While we're at it: what's the best way to parse in a
On Fri, 13 Jan 2012 23:05:19 +0100, Matej Nanut wrote:
> 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 Fri, Jan 13, 2012 at 11:05:19PM +0100, Matej Nanut wrote:
> 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?
[...]
Have you tried:
import std.conv;
...
uint val = parse!
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 wrote:
> Timon Gehr:
>
>> read
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 =
On 01/13/2012 10:34 PM, Jorge wrote:
Thanks for your answer but:
import std.stdio;
import std.conv;
void main()
{
write("Insert number: ");
string s = readln();
auto i = to!int(s);
}
compiles but after i enter a number and press the enter key i get:
std.conv.ConvExcepti
You could also try to!int(str.strip), strip() removes
whitespace from the left and right of a string.
You have to import std.string for it.
On 13 January 2012 22:34, Joshua Reusch wrote:
> Am 13.01.2012 22:16, Piotr Szturmaj wrote:
>>
>> Jorge wrote:
>>>
>>> My first question si very silly:
>>>
>
Ok, it works fine. Thx to you all ;-) and sorry for my noob question.
Am 13.01.2012 22:16, Piotr Szturmaj wrote:
Jorge wrote:
My first question si very silly:
string str = readln()
my input is for example 123
how can i convert this to an integer?
import std.conv;
// then in code:
auto i = to!int(str);
the string returned by readln() ends with NL ('\n'), w
Thanks for your answer but:
import std.stdio;
import std.conv;
void main()
{
write("Insert number: ");
string s = readln();
auto i = to!int(s);
}
compiles but after i enter a number and press the enter key i get:
std.conv.ConvException@.\..\..\src\phobos\std\conv.d(1595):
Jorge wrote:
My first question si very silly:
string str = readln()
my input is for example 123
how can i convert this to an integer?
import std.conv;
// then in code:
auto i = to!int(str);
11 matches
Mail list logo