Hi,
I am trying to read values from a text file that has exactly 5 numbers in each line and all numbers are "tab" separated. numbers could be one digit or two digit.
I am reading it as :
if (map.is_open())
{
int i = 0;
int num;
while (!map.eof())
{
getline(map,line);
if (line == "")
{
continue;
}
else
{
while (line >> map)
{
cout << "Line is " << line << endl;;
int pos1 = 0;
Graph[i].value = GetIntValue(line.substr(pos1+1,pos1+1));
pos1 = line.find(" ");
cout << "Graph[" << i << "] = " << Graph[i].value << endl;
i++;
//I need to make the reminder as my line now -- > this is killing me as I do not know //the length of line..
}
}
}
}
GetIntValue is a small function that takes in a string and returns a int.
basically I need to read each line(lines are exactly 5 in number), store in an array. each line has exactly 5 numbers.
any sort of help would be really appreciated!