What if there are multiple records matching the search query? How about this
Code:bool found=false; while (fread(...) == 1) { if (strcmp(...) == 0) { // ... found = true; } } if (!feof(fp)) { fprintf(stderr, "Error in reading file!\n"); exit(EXIT_FAILURE); } if (!found) { printf("No records found!\n"); }