My program needs to do the following things
Asks the user of the name of the input file
If the user types an incorrect file name (a file name that does not exists in that directory), your code will print the appropriate message and terminate
If the user types the correct file name your program reads the numbers from that file one by one while it keeps a running total
You close that file
You ask the user where he wants the results to be stored
The user types a file name
Your program opens that file for output
Your program writes in that file the result that you had already calculated in step 4
Close the output file
Inform the user that the task was completed
When the user hits ENTER terminate the program
I need help with the validation of the file to check, how to do the count, and using the files that the user wants..
HELP ME PLEASE!!
Code:#include <iostream.h> #include <fstream.h> #include <ios.h> int main() { char f; int number; int count=1; ifstream file; cout << "What is the name of the file you want to read from?"<<endl; cin >> f; file.open("num.txt", ios::nocreate); if (file.fail()) cout << "error opening file"; else { while (count++) { file >> number; count++; } cout << count; file.close(); } return 0; }