Thanks for the suggestion. Tried doing so, up to no avail.
WHole code:
Code:
#include<stdio.h>
#include<string.h>
typedef struct str{
char name[50];//array of structure of variables
char studnum[11];
int age;
float GWA;
}studRec;
void AddStud(int n){
studRec tch[10];
printf("Name:");
scanf("%s", tch[n].name);
printf("Student Number:");
scanf("%s", tch[n].studnum);
printf("Age:");
scanf("%d", &tch[n].age);
printf("GWA:");
scanf("%f", &tch[n].GWA);}
void ViewStud(int n){
studRec tch[10];//viewing
printf("Row Number %d\n", n+1);
printf("Name:");
printf("%s", tch[n].name);
printf("\nStudent Number:");
printf("%s", tch[n].studnum);
printf("\nAge:");
printf("%d", tch[n].age);
printf("\nGWA:");
printf("%f", tch[n].GWA);
printf("\n");
}
main(){
int n, x, viewNum, htr, htx, hty, htz, ........r;
studRec tch[10];
printf("---STUDENT RECORD---\n");
for(;;){
printf("[1] Add Student\n");
printf("[2] Edit Student\n");
printf("[3] View Student\n");
printf("[4] Exit Record\n");
printf("Enter:");
scanf("%d", &x);
switch(x){
case 1: if(........r==10){
printf("Memory Full\n");break;}
else {htz=10-........r;
AddStud(htz); ........r++; break;}
case 2:
printf("Enter which to edit:");
scanf("%d", &hty);
hty--;
ViewStud(hty);
AddStud(hty);
printf("Updated Record:\n");
ViewStud(hty); break;
case 3: for(;;){
printf("Choose an option:\n");
printf("[1] All\n");
printf("[2] One of them\n");
printf("[3] Back to main menu\n");
scanf("%d", &viewNum);
if(viewNum==1){
for(htr=0; htr<10; htr++){
ViewStud(htr);}
}
if(viewNum==2){
printf("Enter the row number:");
scanf("%d", &htx);
ViewStud(htx-1);}
if(viewNum==3) break;}
case 4: break;
default: printf("Invalid; No action allocated so far\n"); break;
}
if(x==4) break;}
}
edit: those dots means 'count'. dunno the one with o removed is a profanity. didn't noticed that