Please help filling in the functions displaycourses(), enternew(), displaydb()
#include
#inc...
Computers and Technology, 24.03.2021 18:50 jaffeisabel
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[]){
;
}
Answers: 3
Computers and Technology, 23.06.2019 12:00
What does the level 1 topic in a word outline become in powerpoint? a. first-level bullet item b. slide title c. third-level bullet item d. second-level bullet item
Answers: 1
Computers and Technology, 24.06.2019 00:30
Use the keyword strategy to remember the meaning of the following word. the meaning for the word has been provided. write your keyword and describe the picture you would create in your mind. obfuscate: to make something so confusing that it is difficult to understand.
Answers: 2
Computers and Technology, 24.06.2019 12:00
An npn transistor is correctly biased and turned on if the a. base is negative. b. collector is negative. c. collector is positive with respect to the emitter and negative with respect to the base. d. collector is the most positive lead followed by the base.
Answers: 1
Computers and Technology, 25.06.2019 07:00
Afile named data.txt contains an unknown number of lines, each consisting of a single integer. write some code that creates two files, dataplus.txt and dataminus.txt, and copies all the lines of data1.txt that have positive integers to dataplus.txt, and all the lines of data1.txt that have negative integers to dataminus.txt. zeros are not copied anywhere.
Answers: 2
Business, 23.01.2021 05:50
History, 23.01.2021 05:50
Mathematics, 23.01.2021 05:50
Physics, 23.01.2021 05:50
Mathematics, 23.01.2021 05:50
Mathematics, 23.01.2021 05:50
Mathematics, 23.01.2021 05:50
Mathematics, 23.01.2021 05:50
Social Studies, 23.01.2021 05:50
Biology, 23.01.2021 05:50