Hi Everyone, retrying c++ after a 10 year hiatus. F/C scientific programmer here :)

So I have this really really long data file. It has a header and I want to locate the heading just before the data rows begin. The heading size may change from different sources, but the heading is always the same. So it's something like

long header
{column titles = AAA BBB CCC DDD EEE ... ZZZ}
{data columns = 111 222 333 444 555 ... 666}
{data columns = 111 222 333 444 555 ... 666}

I got my proggy to read each line and find the first word of the header and check it and then begin reading data...using:

getline(snp_file_in, word, ' ');

but I want to output the header also...but I realized that using

getline(snp_file_in, line);

moves my buffer...

is there a way to rewind the stream pointer? All the examples for peek use characters and I need at least three characters to check if I've reached the heading....and I need to read and output the header.

8 Years
Discussion Span
Last Post by drdaco

perhaps but I don't know how I can implement that to do the check in the meanwhile. What I could do is simply read the file, count the lines until I get my header, put the pointer back, reread + print and then read data.

I was hoping to cut out the rewind part but perhaps it's easiest to implement this way.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.