#include<iostream> #include<fstream> using namespace std; int main() { ofstream outfile("grades.txt", ios::out); if (!outfile) { cerr << "error:output file cannot be opened\n"; exit(1); } char id[9], name[16]; int grade; cout << "\t:"; int n = 1; while (cin>>id>>name>>grade) { outfile << name << " " << id << " " << grade << endl; cout << "\t" << ++n << ":"; } outfile.close(); }