Specific File I/O Question

I don't have any code here yet. However I am wondering how to read a file that starts with an empty line. I haven't been able to find anything so far in my searching, so I was wondering if anyone could point me in the right direction.

My assignment involves reading from a file that starts with an empty line and then progresses till the EOF. I have to convert arithmetic expressions from infix to postfix utilizing a user-made stack template. Will post code later, if I need help. For now, I just need help with the I/O question.
> I am wondering how to read a file that starts with an empty line.

Just throw away the empty lines:

If there is just one emty line at the beginning:
1
2
3
4
std::ifstream file( "whatever.txt" ) ;
std::string line ; 
std::getline( file, line ) ; // just throw it away
// read the rest of the file 


If there are many empty lines:
1
2
3
4
5
6
7
8
9
10
11
std::ifstream file( "whatever.txt" ) ;

std::string line ; 
while( std::getline( file, line ) )
{
      if( !line.empty() ) // if it is not an empty line
      {
             // do something with it
      }
      // else it is an empty line; ignore it
}
Topic archived. No new replies allowed.