Question: File HEAD program: Write a program that asks the user for the name of a file. The program shold display the first 10 lines of
File "HEAD" program: Write a program that asks the user for the name of a file.
The program shold display the first 10 lines of the file on the screen (the "head" 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.
-------------------------------------------------------------------------------
//Please change my code whatever you want to be right answer -Thank you
// HEAD Program
#include
#include
using namespace std;
int main (int argc, char *argv[]) { ifstream in_stream;
//open the file in_stream.open("file.txt");
string data; //count the no of lines read and printed int count=0;
//loop till end of the file while(!in_stream.eof()) { //read the file data getline(in_stream,data); count++;
//if no of lines printed are less than 10 then print if(count <=10) cout< }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
