[sac-user] We don't need no steenking input files

Robert Bernecky bernecky at snakeisland.com
Thu Feb 18 22:20:09 CET 2016


Not exactly what you were hoping for, but the APEX benchmarks
use this to get an int from the command line, e.g.:

    mymain 42

-----------------------

use StdIO : all;
use CommandLine: all;
use String: {tochar,sscanf};

int main()
{
  val = CommandLineArgvXBI( true);
  StdIO::print(val);
  return( 42 == val);
}

inline int CommandLineArgvXBI(bool y)
{ /* Get Command-line argument element #y as integer scalar */
  int z;
  junk, z = sscanf(argv(toi(y)), "%d");
  return( z);
}

Bob

On 16-02-18 03: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
> 


-- 
Robert Bernecky
Snake Island Research Inc
18 Fifth Street
Ward's Island
Toronto, Ontario M5J 2B9

bernecky at snakeisland.com
tel: +1 416 203 0854




More information about the sac-user mailing list