reading in formatted file

Hi Everyone,

I have a question about reading in a file that has been formatted. Below are what the contents of the file looks like:

1
2
3
4
5
6
  A   B   C   D   E
  1   3   2   6   7
  2   2   9   8   4
  .   .   .   .   .
  .   .   .   .   .
  .   .   .   .   .


The first row consists of entirely strings and the remaining rows consist of entirely integers. I want to read in the contents of this file and calculate the average for each column. However, I'm not sure how to get around reading in the first row that is all strings. Any recommendations? Maybe there is a way to skip the first row and just read in the integers? Thanks in advance!
One way is to just use ignore() to skip the first line.

For example to read and ignore any character until the newline '\n' is found.
 
infile.ignore(100, '\n');
The 100 was just a suggested value, it will ignore a maximum of that number of characters.

http://www.cplusplus.com/reference/istream/istream/ignore/
Worked like a charm. Thanks Chervil!
Topic archived. No new replies allowed.