say i have the following text in a file:
.
2546 S d5e3 Bill
5151 C d5e3 Bill
what I want to do is check the first item, if its true i know what to do already. What I cant figure out is how to skip the remainder of the row if I get a false statement.
consider the first column an account number. if its true i will process the information in the row. if its false i want to continue and check the next number. do this until i reach the end of the file.
If you're iterating over and over through the file, there's no way to just "skip" characters to the next line. All you can really do is ignore them. I'm not sure how you're iterating through your text, but if you're just using a repeated getchar than you could just continue grabbing the next character until you find a newline character ('\n'). You could do something like this:
You can move to the next line using inf.ignore(std::numeric_limits<streamsize>::max(), '\n');. However it would probably be much simpler to just loop on your sequence of reads that should consume the whole line anyway:
1 2 3 4 5 6 7 8 9 10 11 12 13
int acc;
char c;
std::string str1;
std::string str2;
while(inf >> acc >> c >> str1 >> str2)
{
// all items read successfully
if(acc == check_acc)
{
// ... deal with account details c, str1 & str2
}
}