Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ using microsoft visual studio express #include <iostream> #include <fstream>

ID: 669164 • Letter: C

Question

C++ using microsoft visual studio express

#include <iostream>

#include <fstream>

File Display Program.

Write a program that asks the user for the name of a file.

The program should display the content of the file on the screen.

If the file’s contents won’t fit on a single screen, the program should display 24 lines of the output at a time, and then pause.

Each time the program pauses, it should wait for the user to strike a key before the next 24 lines are displayed.

Include text file that will be inputed.

Explanation / Answer

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
cout << "Please enter the name of the file: ";
string fileName;
getline(cin, fileName);
ifstream file(fileName.c_str(), ios::in);
string line;
for (int count = 1; !file.eof(); ++count)
{
getline(file, line);
cout << line << endl;
if (count % 24 == 0) system("Pause");
}
system("Pause");
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote