[sac-user] Reading a value from stdin, casting to an int?

Clemens Grelck c.grelck at uva.nl
Fri Feb 19 09:45:35 CET 2016


Hi Rob,

Have a look into the ScalarIO module of the stdlib. The function
you're looking for is this one:

inline bool, int fscanint(File &stream)
{
   int result;

   result=0;
   success, result=File::fscanf(stream, "%d");

   return(success==1, result);
}

This example also shows you how to implement similar functionality.

  Clemens


On 2/18/16 9:17 PM, Rob Stewart wrote:
> Hi,
>
> I'd like to write this:
>
> int main()
> {  x = /* read from stdin once Enter is pressed, cast to int */
>    // x is now an int
>    ..
> }
>
> What is the function call for reading a character from standard, and how
> do I cast this value to an int?
>
> Thanks,
>
> --
> Rob
> _______________________________________________
> sac-user mailing list
> sac-user at sac-home.org
> http://lists.sac-home.org/mailman/listinfo/sac-user


-- 
----------------------------------------------------------------------
Dr Clemens Grelck                                     Science Park 904
University Lecturer                                   1098XH Amsterdam
                                                            Netherlands
University of Amsterdam
Institute for Informatics                        T +31 (0) 20 525 8683
Computer Systems Architecture Group              F +31 (0) 20 525 7490

Office C3.105                             staff.fnwi.uva.nl/c.u.grelck
----------------------------------------------------------------------




More information about the sac-user mailing list