In this program, we are going to share how to count the number of lines in a file using c programming language. If you are a beginner and want to start learning the c programming, then keep your close attention in this tutorial as I am going to share a c program to count the number of lines in a file.
Copy the below c program and execute it with the help of c compiler. At the end of this program, We have shared the output of this program.
#define FILENAME "example.txt"
printf("File \"%s\" does not exist!!!\n",FILENAME);
printf("The total number of lines are: %d\n", linesCount);
The total number of lines are: 10
Tags: c - Retrieving total line numbers in a file, C function that counts lines in file, C program to count lines, C program to count number of lines in a file, C Program to Find the Number of Lines in a Text File, Counting number of lines in the file in C, file - C Program to count comment lines (// and /* */)