Hey Guys,
I find myself at your mercy again...
My function takes a name and some other values along with a registration No, this is in the form of a string of 4 chars the first letter is a char and the following 3 are numeric eg:w123
I have this in the function checking the users input adn it seems fine.
Once I have validated that the user input is in the correct format I want to check if the input has already been used and stored in the database, this is where the code runs but does nothing???
I wonder if any one can see where im going wrong.
Thanks again
C
Code:void add_new_student(void) { char record_id[4]; int check_reg=1; int result; int loop=0; clrscr(); /* Add the name & ID to the database*/ printf("\n\n\t\t Enter New Name And Reg No\n\n"); printf("Enter First Name: "); gets(students_database[index].fname); fflush(stdin); printf("Enter Last Name: "); gets(students_database[index].sname); flush(stdin); printf("Please enter an 4 letter Reg No eg: w123 \n"); gets(record_id); fflush(stdin); /* Validate Reg Number */ while(check_reg) { while(!isalpha(record_id[0]) || !isdigit(record_id[1]) || !isdigit(record_id[2]) || !isdigit(record_id[3])) { printf("Please RE-Enter A Reg No In The Correct Format eg: w123 \n"); gets(record_id); fflush(stdin); check_reg = 1; } check_reg= 0; /* Check if the Reg is taken*/ while(loop < MAX) { result = strcmp(students_database[loop].reg_no,record_id); while(result==0) { printf("This Registration Number Is Taken"); printf("Please Re-enter A Registration Number\n"); scanf("%c",&record_id); fflush(stdin); } loop++; } if(result==1) { strcpy(students_database[index].reg_no, record_id); } } printf("Please Enter The Credits \n"); scanf("%d",&students_database[index].credit); fflush(stdin); while(students_database[index].credit <10) { printf("Credits are between 10-15 please choose again!"); scanf("%d",&students_database[index].credit); fflush(stdin); } while(students_database[index].credit >15) { printf("Credits are between 10-15 please choose again!"); scanf("%d",&students_database[index].credit); fflush(stdin); } /* Increment the array */ index++; menu_controller(); }