i have a sequential file named number.txt it contains the numbers 10 thru 20 . i need to access this file and add a value of one to each number. then create and write to a file called updatedNumbers.txt. this is for school. im trying to get a c to pass. i have took this class twice already. it is online with limted help. i'm so confused and i don't understand a lot of what's going on. i think i make take up heavy drinking if i don't figure out some thing soon. i would appreciate any help. i have posted a thread earlier on another project but have abandoned it it's too much for me. but any way here is my program any advice would be helpful and greatly appreciated.
[tag]
[/tag]Code:#include <iostream> #include <string> #include <fstream> using std::cout; using std::cin; using std::endl; using std::ofstream; using std::ifstream; using std::ios; using std::string; int main() { //declare variables string name = ""; int num = 0; int updatedNum //open and read the file ifstream inFile; inFile.open("numbers.txt", ios::in); //determine whether the file was opened if (inFile.is_open()) { //read a record getline(inFile, name); inFile >> num; while (inFile.eof()) { //display the record cout << name << " " << endl; //read another record getline(inFile, name); inFile >> num; } //end while //close the file inFile.close(); } else cout << "The file could not be opened." << endl; //end if //create file object and open the file ofstream outFile; outFile.open("updatedNumbers.txt", ios::out); //write the updated numbers to the file outFile << heading << endl << endl; outFile << columnHeaders << endl; outFile << underLines << endl; for (int x = 0;x += 1) outFile << num[x] << endl; //end for outFile << endl << ; //close the file outFile.close(); return 0; } //end of main function