question about reading files in
Hi,
I am having a lot of trouble with reading a file in, but being able to ignore the first few lines. This is the file I'm reading in:
######################
#something
#####################
somethingtobereadin1
somethingtobereadin2
I want to be able to ignore the first 3 lines and whitespace, and read in the strings "somethingtobereadin1" and "somethingtobereadin2". I am posting the code I have written so far, I tried reading it in and then using the ignore function. However, I am having lots of trouble trying to figure this out and will appreciate any help anyone can provide. THanks for any help.
Here is the code:
Code:
#include <iostream>
#include <string>
#include <fstream>
int main()
{
ifstream infile;
infile.open("readinfile");
char buffer[50];
string temp;
while (!infile.eof()){
infile>>buffer;
infile.ignore(100,'\n');
infile>>temp;
cout<<temp<<endl;
}
}