codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Beginner Question - Stack Class  bmorrise at 04:18 on Thursday, September 15, 2005
 

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








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime
•  help me
•  pls help me with this..
•  Re: Security - Code verify
•  Job @ EarlySail
•  Job @ EarlySail (perl)
•  IPC problem
•  Re: import contacts of msn/yahoo


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007