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
- Linking Files having same variables with different data types in C
- What’s difference between header files "stdio.h" and "stdlib.h" ?
- C program to print a string without any quote (singe or double) in the program
- 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
- C++ program to create a file
- Program to check if two strings are same or not
- Splint -- A C program verifier
- Program error signals
- Program to print last 10 lines