|
I'm writing a stack class that gets data from a file and performs operations. This is what the file contents look like:
push a 10
push a 50
pop b
pop a
push b 20
push a 20
I tried reading it in like this:
<---START CODE--->
char command[5];
char identifier[2];
int add_item;
ifstream fileToOpen;
fileToOpen.open("/forum/p2datafile.txt");
while (!fileToOpen.eof()) { //Check for the end of the file
fileToOpen >> command >> identifier >> add_item;
//This is where I do stuff
}
<---END CODE--->
This compiles just find, but when it comes to a line without a number it gets stuck and just loops. Do I need to you getline commands or something to get the line and parse it? I don't really know how to do that. Any help would be appreciated. Thanks.
-Ben
|
|
|
|
|
|
|
// |