A file is downloaded and placed in your working directory.
Write a program asking the user for the name of the file in main.
If the file does not exist, the function should use a loop to allow the user
to enter the file name two more times before exiting. If the file is not found, display an appropriate message to the user and exit the program using return 0.
If the file is found, the program should display the contents of the file on the screen and write a copy of the file to a text file named newxxx.txt in your working directory. The xxx represents your initials. This is easiest done as the individual lines are read as input.
Each line of the screen output should be preceded with a line number, followed by a colon and a space.
If the file’s contents will not fit on a single screen, the program should display 20 lines of output at a time, and then pause. Do not use system(“pause”); but use a counter to pause instead. Each time the program pauses, it should wait for the user to strike any key before the next 20 lines are displayed.
Prior to exiting the program, display a message to the user which display the total number of lines in the file.
The file name is "Prog12" and it is a .txt file.
Here's what I have so far...
using namespace std;
//Get the filename from the user.
cout << "Enter the filename: ";
cin >> filename;
//Display an error message.
cout << "Error opening the file.\n";
cout << "Please re-enter the filename: ";
cin >> filename;
//Open the file.
//Close the file.
The professor wants us to use a Do-While loop. How can this be done with a Do-While loop? I can't get my Do-While loop to work.