[try Beta version]
Not logged in

 
convert a string to an integer

Jun 10, 2013 at 1:31am
why do I get an upside-down question mark with the following function?

int FileInfo ()
{
string FileLine;
string index;
FileLine = "6 600 87 88 89 90 91 92 60";
index = atoi((FileLine.substr(0, 1)).c_str());
cout << index << endl;


return 0;
}//end FileInfo

I want to turn the "numbers" in string to integers.
Jun 10, 2013 at 1:49am
You have index declared as a string and then you are trying to put an int inside of it using atoi.

Declare index as an int instead.
Jun 10, 2013 at 2:00am
awesome! Thanks!
Topic archived. No new replies allowed.