Say that I wanted to read the numbers off a tab-delimited spreadsheet file, such as from SomeFile.txt:
1 2 3 4 5
How could I write this?
I know how to use ifstream.getline() to get the text in the line, but I'm not sure how to turn a string that says "453" into an integer value of 453.
I also don't know if there might be a more efficient way of doing it then reading a string and turning it into a number.
The code that I have so far would be:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
//How do I get the numbers out of the line?
I believe it will be read as an integer. You could read each character into a char, determine whether they're numbers by using isdigit(), and put them back into the stream by using ifstream.unget(), but that might be overkill.