Modify Student
Function made to modify a student file
1. linesCount()
function:
linesCount()
function:1.1 Description:
This function counts the number of lines in a file. It reads the file line by line using fgets()
and increments a line counter until the end of the file is reached.
1.2 Syntax:
1.3 Parameters:
file
: A pointer to a file object opened for reading.
1.4 Return Value:
The function returns the number of lines in the file.
1.5 Usage:
This function can be used to determine the number of lines in a file, which can be useful in various file processing operations.
2. updateStudent()
function:
updateStudent()
function:2.1 Description:
This function allows the user to update student information in the database. It prompts the user for the student's last name and first name, searches for the student in the database, and updates their information if found.
2.2 Syntax:
Short Form:
Full Form:
2.3 Function Tasks:
Prompt the user to enter the student's last name and first name.
Search for the student in the database using the
findStudent()
function, If the student is not found, display an error message and return.Open the student's file in read-write mode.
Count the number of lines in the file using the
linesCount()
function.If the file has less than 7 lines:
Close the file and reopen it in write mode.
Prompt the user for the updated student information.
Rename the file to reflect the updated student's name.
Write the updated student information to the file.
Display a success message.
If the file has 7 or more lines:
Close the file and reopen it in write mode.
Read and store the rest of the file starting from line 7.
Prompt the user for the updated student information.
Rename the file to reflect the updated student's name.
Write the updated student information to the file.
Display a success message.
Prompt the user if they want to update module information as well.
If yes, call the
calculateAverage()
function.If no, write back the rest of the file.
Refresh the screen.
Last updated