Add Students
A function made to add students data to database
About: This function is responsible for inputting the data of a student. It prompts the user to enter various information about the student and performs basic validation checks on some fields.
1. studentInput()
function
studentInput()
functionImportant: This function is the core function of the main function: addStudent()
, which will be wrapped later by it
1.1: Description:
This function is responsible for taking input from the user to populate the fields of a student
structure. (reference: Structures (structs))
1.2: Syntax:
short form:
full form:
1.3: Parameters:
e
: Pointer to astudent
structure (see in Structures (structs)). The input values entered by the user will be stored in the fields of this structure.
1.4: Input:
The function prompts the user to enter various details of the student, such as their ID, first name, last name and home address. The input values are read from the terminal.
for Email and Age, function firstly creates a label called "CHECKPOINT" before input, then it prompts the user to enter it's data, after that function calls the check() function (explained in: Input Checker Function) to verify if input data are valid or not, if it's not it tells user that data are invaild and takes him back to reprompt that kind of data again:
1.5: Output:
The function does not return any value. Instead, it populates the fields of the student
structure passed as a parameter.
1.6: Usage:
This function will be called and wrapped by studentInput() when we need to gather input for a student object.
2. addStudent()
function
addStudent()
function2.1: Description:
This function allows the user to add multiple student records. It prompts the user for the number of students to add, creates a directory for storing student data files if it doesn't exist, and then iteratively collects input for each student.
2.2: Syntax:
short form:
full form (definition):
2.3: Input:
The function prompts the user to enter the number of students to add and provides a prompt for entering student data using studentInput()
function.
2.4: Output:
The function creates a directory named "database" (if it doesn't already exist) to store student data files.
in this line:
We here create a folder called "database/"
when it doesn't exist already.
but this syntax only supports Unix-Like systems (Linux/MacOS)
For Windows we use this instead:
It saves the entered student data into separate text files, with each file containing the details of one student. The file names are generated using the student's first name and last name.
2.5: Usage:
This function can be used to interactively add student records to a database-like system.
It seems that the code snippet is missing the definition of the student
structure and the implementation of the check()
function, which are referenced within the code.
Make sure to keep them defined by including the"headers/structures.h"
and"headers/checker.h"
appropriately to ensure the code compiles and functions correctly.
Last updated