ok...i am trying to figure out how to read input ....
i am reading input from the command line
sh% ./a.out < input_file
within the input_file, it looks like this:
0 4 6 7 3
1 3 6 7 4 3 6
2 3 6 7 3 2 4 6 7 7
3 5
4 3 2 9 1
and im looking to read in the whole thing .... in each line, the first number is the item #, and the rest of the numbers is some attributes for that item number ... and each line is a different item # ...
i know how to get it to read in the whole file:
while (!cin.eof())
{
//reads in everything until the end of the file
}
but how do i get it to read in until the end of the line (every line can have a different number of attributes)?
i was going to have another while loop within it?
here is some code:
#include<iostream>
int main()
{
int input;
while (!cin.eof())
{
//reads in everything until the end of the file
while (?????)
{
//reads in each line
}
}
do i read until i find \n ?
while (input != '\n')
??
any help would be great..thanks