Student Database Problem

0 sara v · May 31, 2015
Hey Bucky! 
Need some help with an issue I'm having with my code (student database) 
I'm having some trouble modifying student's record and I don't understand why. Could you please have a look? I would appreciate it a lot.Thanks in advance. 


void Modifikim() //void function added to the main one 

int select3; 
char choice3; 
int isFound = 0; 
char IDno; 
char s_id[15]; 
while(select3!=2){ 
system("cls"); 
printf("\n\t\t ======================================"); 
printf("\n\t\t | MENU: |"); 
printf("\n\t\t | |"); 
printf("\n\t\t | [1] Modify sudent's mark |"); 
printf("\n\t\t | [2] Back to the main menu |"); 
printf("\n\t\t ======================================"); 
printf("\n\t\t\tSelect: "); 
scanf("%d", &select3); 


switch(select3){ 
case 1: 

system("cls"); 
printf("\n\t\t\t\t-MODIFY STUDENT'S MARKS-"); 
printf("Enter ID to Modify: "); 
fflush(stdin); 
gets(s_id); 
fp = fopen("studentfile.txt","rb+"); 
while(fread(&stu, sizeof(stu),1,fp) == 1){ 
if(strcmp(s_id, stu.ID_no) == 0){ 
fflush(stdin); 

for(int i=0;i

Post a Reply

Replies

Oldest  Newest  Rating
0 c student · May 31, 2015
some indenting would be nice, anyway...
your fflush() behaviour is undefined:
fflush(stdin); 

from man page: "The standards do not specify the behavior for input streams."
man page: http://linux.die.net/man/3/fflush

gets buffer overrun warning.

fp undeclared here unless it was a global define (i don't know, i deduce what i see):
fp = fopen("studentfile.txt","rb+"); 

same for your stu struct.

the rest of your code is cut off.
0 name family · May 31, 2015
here is the complete code for those who gonna solve the problem 
that is too long :P 

http://paste.ofcode.org/wnnwGmPKaGgPDNybZf4PUg
  • 1

C

107,229 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator