Search Student
A function made to search a student from database by his name
1. search_database() function:
search_database() function:1.1: Description:
1.2: Syntax:
Short Form:
//Routin
void search_database(char* name_or_lastname);
//Function call
search_database("Joe");Full Form:
void search_database(char* name_or_lastname) {
DIR *dir;
struct dirent *ent;
char filename[100];
FILE *file;
if ((dir = opendir("database")) != NULL) {
while ((ent = readdir(dir)) != NULL) {
if (strstr(ent->d_name, name_or_lastname) != NULL) {
strcpy(filename, DATABASE_PATH);
strcat(filename, ent->d_name);
file = fopen(filename, "r");
if (file) {
printw("File %s:\n", filename);
char line[256];
while (fgets(line, sizeof(line), file)) {
printw("%s", line);
}
fclose(file);
} else {
printw("Error opening file %s\n", filename);
}
}
}
closedir(dir);
} else {
printw("Error opening database directory\n");
}
}1.3: Parameters:
Argument
Description
1.4: Input:
1.5: Output:
1.6: Usage:
2. searchStudent() function:
searchStudent() function:2.1: Description:
2.2: Syntax:
Short Form:
Full Form:
2.4: Function Tasks:
Last updated