Howdy.
I'm creating a routine to read text files and perform graphic loading operations based on the findings. An example text file looks like this:
createspritesload
data/001_sprites_smally.bmp
createspritescopyfliphorz
1
6
The first command, 'createspritesload', instructs the program to load in the bitmap file named in the next line (the program then creates sprites from this file).
The second command, 'createspritescopyfliphorz', is supposed to instruct the program to create copies of some of these sprites and flip them horizontally.
It all works fine apart from, I need the program to read in the two values (1 and 6 in this case) after 'createspritescopyfliphorz'. These values tell the program to copy and flip six sprites starting from sprite number 1.
I know how to read text from the file and store the text in a string:
std::string line;
while(file)
{
getline(file, line);
//etc
}
But how can I read a value and store it in an integer? I know how to read ints from binary files but of course this is a text file.
Or do I load the line with getline and convert the contents to an int? If so, how?
Thanks!
_
[Edited by - darenking on July 5, 2005 2:03:21 AM]