We are given almost two identical files. But some characters are corrupted. We need to find the line number and their position where those corrupted letter exists as well as Total number of corrupted (error) letters.
Input : file1.txt contains it is fun file2.txt contains it is run Output : Line Number : 2 Error Position : 1 Total Errors : 1
Prerequisite : getc() in C
1.> Open two file using File pointer in read only mode.
2.> Fetch data of file in two char variable one by one until end of file.
3.> If variable encounter new line then increment line number and reset position to zero.
4.> If variables are not equal then increment number of error and print error line as well as error index.
Line Number : 2 Error Position : 1 Total Errors : 1
This article is contributed by Aditya Kumar. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- C Program to list all files and sub-directories in a directory
- C Program to merge contents of two files into a third file
- What’s difference between header files "stdio.h" and "stdlib.h" ?
- Linking Files having same variables with different data types in C
- Problem in comparing Floating point numbers and how to compare them correctly?
- C program to print a string without any quote (singe or double) in the program
- Hello World Program : First program while learning Programming
- C program to detect tokens in a C program
- Output of C Program | Set 29
- How to compile 32-bit program on 64-bit gcc in C and C++
- How does a C program executes?
- Program to compute Log n
- Splint -- A C program verifier
- Program to check if two strings are same or not
- OpenMP | Hello World program