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, 21.06.2019 13:30
The source manager dialog box allows you to create sources, copy sources created and used in all the documents, modify sources an add bibliographic information to placeholders. true or false
Answers: 2
question
Computers and Technology, 22.06.2019 14:30
Complete the sentence based on your knowledge of the professional difficulties faced by music artists. digital technology allows audiences to see free live telecasts of music or dance performances through
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
How do you write an argumentative essay about the importance of free enterprise ?
Answers: 1
question
Computers and Technology, 23.06.2019 18:00
Freya realizes she does not have enough in her bank account to use the debit card. she decides to use a credit card instead. which questions should freya answer before using a credit card? check all that apply. can i pay at least the minimum payment each month? can i make payments on time and avoid late fees? will i have to take out a loan? how much in finance charges can i afford to pay? should i talk to a consumer credit counseling service?
Answers: 1
You know the right answer?
Please help filling in the functions displaycourses(), enternew(), displaydb() #include
#inc...
Questions
question
Mathematics, 01.09.2020 22:01
question
History, 01.09.2020 22:01
question
Mathematics, 01.09.2020 22:01
Questions on the website: 13722362