Q: Write a C program to Search a Record in Binary File in C Programming.
What is the input of Record Search C Program?
This C program will input a field to start a search with. For example, in a student binary file, we will input roll number of the student to start search in c file.
How To Search A Record In Binary File?
When we have a given roll number to start search with, we will open the binary file in read mode:
/*open binary file in read mode*/
If the file has been opened successfully, we will use a while loop to read file one record at a time until EOF is reached.
First of all we use fread() function to read first record. The roll number of currently read record is matched with given roll no. if both are matched, we display record.
Similarly, the program will read all records one by one and compare with given roll no. If no such record is in the binary file, we will display “Record Not Found Message”.
The source code of Record Search Program in Binary File using C Programming is:
3,384 total views, 2 views today