The numbers I have to read from the file look like this: 1,5,26,3,86,35
I managed to read each number seperately, but my problem is with numbers that are more than one digit. eg 26 or 86.
How can I read them as one number instead of 2 6 and 8 6?
This is what I have sofar:
int main()
{
fstream numbers;
string line;
int num;
numbers.open("test.txt");
if(!(numbers))
cout<<"error: file could not be read."<<endl;
while(getline(numbers,line))
{
for(int i = 0; i<line.length();i++)
{
if(isdigit(line[i]))
cout<<line[i]<<endl;
}
}
}
Thank you.