I got the program to work without files but implementing files just isn't working out: could anyone help me use files with the void Add, etc format
CODE BELOW:
Code:/*GLOBAL COMPUTER SCHOOl*/ /*STUDENT DATABASE*/ #include <stdlib.h> #include <stdio.h> #include <ctype.h> int main() { printf("\t\t\t************************\n"); printf("\t\t\t GLOBAL COMPUTER SCHOOL"); printf("\n\t\t\t************************\n"); struct GCS //Declaring Global Database { char sfname [20]; char slname [20]; char DOB[20]; char mother [20]; char father [20]; }; struct GCS student[50]; //Declaring a student database under Global Database int scount; //Count number of students in database char test = '\0'; //Tests value to cease inputs printf("\n*******************************************************************************\n"); /* Draw the top of the box */ for(scount = 0; scount < 50; scount++) { int option; printf("1.\tAdd Student\n2.\tDelete Student\n3.\tList Student\n4.\tEdit Students\n5.\tExit\n\n"); printf("\nWhich do you want to do?"); scanf("%d" , &option); switch (option) { case 4: printf("Which Student?\n"); scanf("%d", &option); case 5: { printf("\nTHANK YOU for using the GCS...\n"); break; } case 1: { printf("\nAre you sure you wish to add students (y or n)?", scount? "nother ": ""); scanf(" %c", &test); if(tolower(test) == 'n') break; printf("\nEnter Student's First Name: "); scanf("%s", student[scount].sfname); //Reads the student's first name printf("\nEnter %s's Last Name: ", student[scount].sfname); scanf("%s", student[scount].slname); //Read the student's last name printf("\nEnter %s %s DOD (mm-dd-yyyy): ", student[scount].sfname,student[scount].slname); scanf("%s", student[scount].DOB); //REads the student's DOB printf("\nEnter %s %s Mother's Name: ",student[scount].sfname,student[scount].slname); scanf("%s", student[scount].mother); //REad PArent First Name printf("\nEnter %s %s Father's Name: ",student[scount].sfname,student[scount].slname); scanf("%s", student[scount].father); //REad Parent Last Name } case 3: { printf("Students in GCS Database include: \nNAME:\t %s %s \nDOB(mm/dd/yyyy): %s \nParents:\t %s & %s\n", student[scount].sfname,student[scount].slname,student[scount].DOB,student[scount].mother,student[scount].father); for(int i = 0 ; i<scount ; i++ ) { printf("\n\n Student: \t %s %s \n DOB (mm/dd/yyyy): %d \n Parents' Name: %s & %s\n", student[i].sfname, student[i].slname, student[i].DOB, student[i].mother, student[i].father); printf\n"); /* Draw the bottom of the box */ } } system("PAUSE"); return 0; } } }



LinkBack URL
About LinkBacks


