Hi Guys,
Im working on an exersiz that requires the user input a name , 4 scores and an ID number for the record being added.
I had it all going but when I try to add the ID numbers taken from the user and do a check to see if the number is taken ive got a little lost.....
I wonder if anyone can point out the flaws in my function below?
Regards as ever
Colin
Code:void add_new_name(void) { int found=0; int record_id; int loop=0; clrscr(); /* Add the name and DOB & ID to the database*/ printf("\n\n\t\t Enter new name and Grades\n\n"); printf("Enter new name: "); gets(names_database[index].name); flush(stdin); printf("Please enter 4 grade marks in as a percentage value:\n\n"); scanf("%d%d%d%d",&names_database[index].grade1, &names_database[index].grade2,&names_database[index].grade3,&names_database[index].grade4); fflush(stdin); printf("Please enter an ID number between 100-999\n"); scanf("%d",&record_id); fflush(stdin); while(found=0 && loop < MAX) { if(record_id == names_database[loop].id) { printf("This ID number is taken"); printf("Please Re-enter an ID number between 100-999\n"); scanf("%d",&record_id); fflush(stdin); } loop++; } if(found=0) { names_database[loop].id = record_id; } /* Increment the student array */ index++; }



LinkBack URL
About LinkBacks


