Can anyone explain to me why this simple file output program is not working? After running the program and entering some values, I check out the file but nothing gets written! :(
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
#include <fstream>
#include <string>
usingnamespace std;
int main(){
string grade[10];
fstream textfile;
textfile.open("exam.txt");
for(int x=0;x<10;x++){
cout << "Enter a grade for a student: "; getline(cin, grade[x]);
}
for(int x=0;x<10;x++){
textfile << grade[x] << endl;
}
textfile.close();
}