Line 1: You're passing
struct student ss
by value. Since it is passed by value, you can't use it to return anything. It also doesn't appear that you're using any values passed in. In which case, you should just declare it as a local variable.
Line 7 suggestion: If you can't open the file, display a message and return immediately rather than embedding your entire function within an if(fp != NULL)
1 2 3 4
|
if (! fp)
{ cout << "File could not be opened" << endl;
return;
}
|
Lines 15-21: You're asking for the student name, but comparing against the faculty number.
Lines 20-27: You're not reading fp anywhere. What's the point of comparing ss.fac_No with the user input xfac_No? Did you mean to read fp into ss? As the code reads, you're comparing against the struct that was passed in each time through the while loop? You're going to hang in the loop since unless the file is empty, eof() will always be false.,
Line 39-43: Same comments as lines 20-27.
Lines 30, 49, 65: Assuming
get_record
is called from menu, you're calling menu recurrisively. This is going to cause problems. You should simply
return;
to the calling function (menu).
Lines 58-62: Same comments as lines 20-27.