I will use char * fgets ( char * str, int num, FILE * stream ) ;
to do this
1/ count how many space in 1 str.. then you know the column
2/ use loop to count how many str you get ( loop is stopped when str=eof) .. each str you get is a line..
@cstrieder: write your idea, then code it.. if it's wrong, post here.. everyone will solve the problem for you.. ... nobody write code for you
To get the columns you can do pretty much the same. Rather than use an std::ifstream, you make up a std::istringstream and initialise it with the line. Then you can use the same loop to read the content of the line.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
#include <sstream>
#include <string>
int main()
{
std::string line = "12 14 16 18 20 24";
std::stringstream is(line);
int n;
while (is >> n)
std::cout << n << std::endl;
return 0;
}