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 firstname.lastname@example.org. 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
- C program to print a string without any quote (singe or double) in the program
- C program to detect tokens in a C program
- Program to compute Log n
- Output of C Program | Set 29
- How does a C program executes?
- How to compile 32-bit program on 64-bit gcc in C and C++
- Program to print last 10 lines
- Program to validate an IP address
- C++ program to create a file
- Quine - A self-reproducing program
- Program for Sum of the digits of a given number