answersLogoWhite

0


Best Answer

#include <iostream> #include <fstream> using namespace std; int number_of_lines = 0; void numberoflines(); int main(){ string line; ifstream myfile("textexample.txt"); if(myfile.is_open()){ while(!myfile.eof()){ getline(myfile,line); cout<< line << endl; number_of_lines++; } myfile.close(); } numberoflines(); } void numberoflines(){ number_of_lines--; cout<<"number of lines in text file: " << number_of_lines << endl; }

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Program in c language that acceps a file as input and prints the number of lines in it?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Create a program which accepts a number not less than 10The program prints the reverse of the number?

ten


Do a program with turbo pascal to print the alphabet backward?

Turbo Pascal is a style of computer programming. This type of writing language can be used to create a program that prints the alphabet backwards.


Write a program that read phrase and print the number of lower-case letter in it using function of counting?

write a program that reads a phrase and prints the number of lowercase latters in it using a function for counting? in C program


What is hello world?

Hello world is the canonical program that all programming languages use to introduce new programmers to the language. The program simply prints the text "Hello world" via console output and helps programmers quickly identify the key difference in each specific language's implementation of that program.


Assembly language program to check whether the number is even or odd?

;Program to check whether the value in register is even or odd .ORIG X3000 AND R2,R1,X0001 BRZ EVEN LEA R0,DEF ;PRINTS ODD IF VALUE IN REGISTER R2 IS 1 PUTS HALT EVEN: LEA R0,ABC ;PRINTS EVEN IF VALUE IN R2 IS 0 PUTS HALT ABC .STRINGZ "EVEN" DEF .STRINGZ "ODD" .END


How did menu's develop?

A restaurant prints it out using a special program


How do you write a c program that prints a box an oval an arrow and a diamond?

You first learn how to program in C.


What is the phone number of the Ambers Originals And Prints in Chesterfield Virginia?

The phone number of the Ambers Originals And Prints is: 804-739-7466.


Dry run table in flow-chart?

/* my second program in C++ with more comments */ #include &lt;iostream&gt; using namespace std; int main () { cout &lt;&lt; "Hello World! "; // prints Hello World! cout &lt;&lt; "I'm a C++ program"; // prints I'm a C++ program return 0; }


Program in c to develop an algorithm that prints the n value of algorithm?

reymond rillera reymond rillera


Why MsgBox with string 000 prints e but 00 or 0000 are printed correctly Thank you ozcansyahoocom?

Your program is wrong.


What might EA stand for on a Salvador Dali lithograph?

When an artist is commissioned to do a project they are often allowed access to a certain number of prints with which they can do what they like. These prints are usually marked "EA" to indicate that they are prints intended for use by the artist.