www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - int input

reply Rayne <DiscipleRayne gmail.com> writes:
I was wondering, since you can't cast readln, how would you get int input from
the user? I know this is a newbish question, but yeah I'm not sure.
Sep 09 2008
next sibling parent reply "Chris R. Miller" <lordSaurontheGreat gmail.com> writes:
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Rayne wrote:
 I was wondering, since you can't cast readln, how would you get int inp=

e. To parse? In tango it's in a parser in tango.text.convert.Integer and Float. I don't use Phobos, so if that's the library you're using I'm sorry but I can't help (there should be an importable parser...) Which gave me another idea, but I'll start it in a different thread so as to not hijack yours.
Sep 09 2008
parent Rayne <DiscipleRayne gmail.com> writes:
Chris R. Miller Wrote:

 Rayne wrote:
 I was wondering, since you can't cast readln, how would you get int input from
the user? I know this is a newbish question, but yeah I'm not sure.

To parse? In tango it's in a parser in tango.text.convert.Integer and Float. I don't use Phobos, so if that's the library you're using I'm sorry but I can't help (there should be an importable parser...) Which gave me another idea, but I'll start it in a different thread so as to not hijack yours.

Sep 09 2008
prev sibling next sibling parent reply "Denis Koroskin" <2korden gmail.com> writes:
On Wed, 10 Sep 2008 08:09:00 +0400, Rayne <DiscipleRayne gmail.com> wrote:

 I was wondering, since you can't cast readln, how would you get int  
 input from the user? I know this is a newbish question, but yeah I'm not  
 sure.

Maybe you need this: int i; read(i); // read an integer from console
Sep 10 2008
parent Rayne <DiscipleRayne gmail.com> writes:
Denis Koroskin Wrote:

 On Wed, 10 Sep 2008 08:09:00 +0400, Rayne <DiscipleRayne gmail.com> wrote:
 
 I was wondering, since you can't cast readln, how would you get int  
 input from the user? I know this is a newbish question, but yeah I'm not  
 sure.

Maybe you need this: int i; read(i); // read an integer from console

That doesnt work.
Sep 10 2008
prev sibling parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
"Rayne" wrote
I was wondering, since you can't cast readln, how would you get int input 
from the user? I know this is a newbish question, but yeah I'm not sure.

use din from std.cstream: din.read(myint); -or- din.readf("%d", &myint); -Steve
Sep 10 2008
parent reply Rayne <DiscipleRayne gmail.com> writes:
Steven Schveighoffer Wrote:

 "Rayne" wrote
I was wondering, since you can't cast readln, how would you get int input 
from the user? I know this is a newbish question, but yeah I'm not sure.

use din from std.cstream: din.read(myint); -or- din.readf("%d", &myint); -Steve

Sep 10 2008
parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
"Rayne" wrote
 Steven Schveighoffer Wrote:

 "Rayne" wrote
I was wondering, since you can't cast readln, how would you get int 
input
from the user? I know this is a newbish question, but yeah I'm not sure.

use din from std.cstream: din.read(myint); -or- din.readf("%d", &myint); -Steve


yw :) Yeah, I didn't think to look for it their either, I ended up doing a grep for "readf" in order to find it the first time (which is in std.stream I think), then I don't remember how I figured out to look for din :) Of course, I don't generally use Phobos... -Steve
Sep 10 2008