Write a program that asks the user for the name of a file . The program should d
ID: 3767985 • Letter: W
Question
Write a program that asks the user for the name of a file . The program should display the last 10 lines of the file on the screen( the "tail of the file ") . if the file has fewer than 10 lines, the entire file should be displayed , with a message indicating the entire file has been displayedWrite a program that asks the user for the name of a file . The program should display the last 10 lines of the file on the screen( the "tail of the file ") . if the file has fewer than 10 lines, the entire file should be displayed , with a message indicating the entire file has been displayed
Explanation / Answer
#include<iostream.h>
#include<string.h>
#include<fstream.h>
using namespace std;
int main()
cout<<“enter the name of the file”;
cin>>filename;
string fileName;
input;
string line;
int counter=0;
cin>>counter;
getline(filename);
do(getline(file,line))
{
while(getline(filename))
counter++;
}
if(counter<10)
cout<<“display 10 lines”;
}
do(getline(file,line)
{
while(counter<=10)
cout<<line;
}
counter++;
break;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.