Where '/' is delimiter.
I don't understand any form of getline it's trying to make me retype and this site doesn't help me understand either. How would I read properly from a file using fstream?
#include <iostream>
#include <fstream>
usingnamespace std;
int main()
{
int x[5];
ifstream f("data.txt");
// read the numbers from the file
int ix = 0;
while (ix <5 && f >> x[ix])
ix++;
// show the contents of the array
for (int i=0; i<ix; i++)
cout << x[i] << endl;
return 0;
}
The while condition may need some explanation. It is checking two separate conditions, first that the array is not full, then that reading of an integer has been successful.