C Programs 55 Lessons

C Program to Find the Number of Lines in a Text File

Number of lines in a file can be determined by counting the number of new line characters present. #include <stdio.h> int main() / Ask for a filename and count number of lines in the file/ { //a pointer to a […]

    C Program to Replace a Specific Line in a Text File

    This C program is used to replace a specific line in a text file. #include <stdio.h> int main(void) { FILE fp1, fp2; //'filename'is a 40 character string to store filename char filename[40]; char c; int del_line, temp = 1; //asks […]

      C Program to Delete a Specific Line From a Text File

      In this program, user is asked for a filename he needs to change. User is also asked for the line number that is to be deleted. The filename is stored in 'filename'. The file is opened and all the data […]

        Scroll Back to Top