subject

Please help filling in the functions displaycourses(), enternew(), displaydb() #include
#include
#include
#include

#define SIZE 30
#define fieldLength 200

#define diskFile "diskFile. dat"
#define courseFile "course. txt"

struct db_type
{
char name[fieldLength];
int age;
char course1[fieldLength];
char course2[fieldLength];
char status[fieldLength];
};

struct courseInfo
{
char code [20]; // e. g., EECS2030
char title [fieldLength];
char date [20];
char time_start [20];
char time_end [20];
char location [20];
};

struct courseInfo courseArr[SIZE]; // global variable array of struc

char prompt_menu(void);
void init_list(struct db_type * pArr[]);
void clearDB(struct db_type * pArr[]);
void init_courseArr(void);

void writeDisk(struct db_type * pArr[]);
void emptyDisk(void);
void loadDisk(struct db_type * pArr[]);

int main(int argc, char *argv[])
{

struct db_type * db_pArr[SIZE]; // main db storage

init_list(db_pArr); // set to NULL

init_courseArr(); // load course from diskfile

char choice;
for(; ;){
choice = prompt_menu();
switch (choice)
{
case 'n': enterNew(db_pArr); break;
case 'd': displayDB(db_pArr); break;
case 'w': writeDisk(db_pArr); break;
case 'l': loadDisk(db_pArr); break;
case 's': sort(db_pArr); break;

case 'c': clearDB(db_pArr); break;
case 'e': emptyDisk();break;

case 'v': displayCourses();break;
case 'p': swap(db_pArr); break;
case 'r': removeRecord(db_pArr);break;

case 'q': exit(1); // terminate the whole program
}

}
return 0;
}

void init_list(struct db_type * pArr[]){
int t;
for (t=0; t {
pArr[t]= NULL;
}
}

void clearDB(struct db_type * pArr[]){
char c3[3];
printf("are you sure to clear db? (y) or (n)? ");

fgets(c3,3,stdin);

if(! strcmp(c3, "y\n"))
init_list(pArr);
}

char prompt_menu(void){
char s[80];
while(1){
printf("\n\n");
printf("| %-20s","(N)ew record");
printf("%-20s","(R)emove record");
printf("Swa(p) records\t|\n");
printf("| %-20s","(S)ort database");
printf("%-20s","(C)lear database");
printf("(D)isplay db\t|\n");

printf("| %-20s","(L)oad disk");
printf("%-20s","(W)rite disk");
printf("(E)mpty disk\t|\n");

printf("| %-20s", "(V)iew courses");//|\tSwa(p) record\t(Q)uit\t\t\t\t|\n");
printf("%-20s","(Q)uit");
printf("*Case Insensitive*\t|\n");
printf("\n");
printf("choose one: ");

fgets(s,50, stdin); // \n added

if (strlen(s) == 2 && strchr("edlsuqrcwnvpr", tolower(*s)))
return tolower(*s); // s[0], return the first character of s
//else
printf("not a valid input!\n");

}
}

/* display all or specified course */
void displayCourses(void){
; // the provide PE2.out uses "%s\t%-40s%-5s %s-%s %s\n" as formatting string for printing each course info

}

/* input items into the list */
void enterNew(struct db_type * pArr[SIZE]){
;

}

/* display records */
void displayDB(struct db_type * pArr[]){
;

}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:30
If the polar bear were taken out of the food chain what would happen to the seal population the seal population would diminish the seal population would grow dramatically the seal population would stay the same the seal population would decrease slightly
Answers: 1
question
Computers and Technology, 22.06.2019 15:10
Which activity should be part of a long-term plan to positively affect yourhealth? oa. wearing regular clothing when handling toxinsob. not worrying about secondhand smokeoc. avoiding excessive exposure to sunlightod. drinking only well water
Answers: 1
question
Computers and Technology, 24.06.2019 09:40
Healthy study habits are best described as
Answers: 1
question
Computers and Technology, 24.06.2019 12:10
What is it called during the editing process when the processor ensures that a character holding a coffee mug from one angle is holding the same mug in the same way when the shot switches to another camera at another angle? cinematography continuity technology prop use
Answers: 1
You know the right answer?
Please help filling in the functions displaycourses(), enternew(), displaydb() #include
#inc...
Questions
question
Mathematics, 24.10.2021 15:20
question
Mathematics, 24.10.2021 15:30
question
Mathematics, 24.10.2021 15:30
question
Mathematics, 24.10.2021 15:30
question
History, 24.10.2021 15:30
Questions on the website: 13722360