question on reading from a file

This is a discussion on question on reading from a file within the C++ Programming forums, part of the General Programming Boards category; I need to read some info into a couple of stacks. How can I read different info into each stack ...

question on reading from a file

I need to read some info into a couple of stacks. How can I read different info into each stack using only 1 input file. Is there a way to signal the program to only read for example two lines then the next two lines are for the next stack?? If I use an end of file condition everything is read into the first stack, correct?? I wasn't given option to set the size of the stack to only fit the data need so both stacks are the max size. The stacks are going to be filled with characters so a sentinel value has not worked.

"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

Of course, such low level solutions should be avoided except where they actually improve the readability and reliability of the program. However, since the more abstract methods are already debugged and tested, they should be tried first.

Speaking of low level, C-strings are a pain to work with. Pretty much the only people who use them in C++ are die-hard C programmers that are completely comfortable with the issues, and beginners that don't know any better or are denied the better solutions by their teachers. This is a better way to get a line:

strings are very good. look up cppReference
and get the function listings. Also, you can use the + operator to concatenate, and the = operator to assign. no more strcat() or strcopy() again for me..... string looks nicer than char [] as well.