fstream

Started by
2 comments, last by _Madman_ 20 years, 11 months ago
Could you please tell me how can I read (skip) line in fstream. For ex. I read the first char, if it is equal to smthn. then I read folowing int''s, if not, I skip to next line. I am using file.getline(buff,size,''\n''); now, but that means data is read in buffer, actually all I need is skip to next line. sscanf/ffscanf had %*w notation to disable writing. ______________________________ Madman
______________________________Madman
Advertisement
file.ignore(INT_MAX, ''\n'');
Thanks!
Is that INT_MAX maximal number of chars to skip?

______________________________
Madman
______________________________Madman
INT_MAX is the maximum signed int value, and should be defined as something like 2147483647. it's defined in climits (or limits.h), but i believe iostream or fstream includes this, so you shouldn't need to. You could substitute INT_MAX with any value you wanted in the ignore function - for example if you wanted to skip only a certain amount of characters - but since you want to toss the whole line, the INT_MAX pretty much guarantees you'll hit everything on the line before \n

[edited by - bjl3784 on May 5, 2003 10:31:46 AM]

This topic is closed to new replies.

Advertisement