Is there an easy way to read in numbers from a text file? The problem I have is that some are double digit numbers i.e. '40 12 6 15'. Because 'number' is an int it only brings in one at a time. Is there a way to include everything in infile until I reach a space?
I've got code like this:
Code:int number; ifstream infile ("C:\\C++\\numberstxt"); if(!infile) { cout << "Can't open numbers.txt"; cin >> hold; return(-1); } infile >> number;
If ifstream is usable with fscanf sometrhing simple as
Code:
while (fscanf(fp,"%i", &targetBuffer++) != EOF)
Though even in C there might be a more elegant solution.