Question about reading data from an infile

Hello im a beginners computer science class and ive been asked to asked to create some code that will read information from a file and reprint that information into another file.

I understand just about everything but the one thing ive been trying to do is ignore a line of data as theres 2 lines in the file that we dont need to use.

the infile looks like this

12345678 2015 07 11
Jose Conseco
5178 north street
New York, NY 12345
34 24 Red Flower

I need to use the first two lines, skip the next two, and use the last line.
Right now im assigning variables to everything and then just not using the ones i dont need.

I have seen that you can use a loop but my class has yet to get to loops yet so id rather not.

My class notes mention something about an inFile.ignore command but i cant get that to work for some reason.


Last edited on
What would be the correct way to use ignore to skip a line in an infile?

i tried std::inFile.ignore(256,'\n'); and just InFile.ignore(256,'\n') but both are giving errors when compiled
both are giving errors when compiled
What are the errors?
What is the exact error message?


std::inFile is definitely wrong, unless you have declared the inFile within namespace std. The namespace std is reserved for C++ Standard Library, and therefore you should never declare anything within it.
Topic archived. No new replies allowed.