By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,148 Members | 1,363 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,148 IT Pros & Developers. It's quick & easy.

C++ fstream

P: 9
I am have tried unsuccessfully to remove or ignore lines that contain integers from an input file. This is what I am using to extract lines from the file. I have looked up the ignore() function but I don't think that will help me do this. Does anyone have any suggestions? Thanks.

Expand|Select|Wrap|Line Numbers
  2. while (INFILE)
  3. {
  4.  getline(INFILE, line) ;
  5. ...
  6. ...
  7. }
The input file contains data like:
Who are you
I Know

I am trying to get the string line to receive :

Who are you
I Know
Mar 23 '07 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 8,916
I do not think you will have much success becuase getline gets a line (the clue is in the function name) from a file.

Since you data is spread accross multiple lines in the file it will require several getline calls to retrieve it.

You need to load the lines individually make the decision on whether to keep or discard them and if keeping them add them to the store of kept lines (which you will also have to create).
Mar 23 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.