// File name: grade.cpp // Topic: file input/output in C++ // Created: March 13, 2000 // Author: Elena Machkasova #include #include //using file input-output int main() { // array to store the name (no more than 8 characters) char username[9]; // One extra for null char. // integer to store the score int score; //declare input and output streams ifstream inFile; ofstream outFile; // open input and output files: // Exercise 1: open inFile to read from the file "data": // Exercise 1: open outFile to write to the file "result": // checking if the files have opened correctly: if (!inFile) { //print error message to standard error stream: cerr << "Can not open input file" << endl; exit(1); } if (!outFile) { //print error message to standard error stream: cerr << "Can not open output file" << endl; exit(1); } // input-outpur loop goes until the end of file or until wrong data while (inFile >> username >> score) { // Exercise 1: write to the output file // the same username and the score increased by 10: } // Exercise 1: close both the input and the output files return 0; }