whenever i log in as admin... then logout...
it automatically logs in as student and shows the student menu....
i can figure out why... here's my main code... if you want to see the rest of the code, ill post but i think its only in my main.... any suggestions?
Code:
int main(void)
{
STUDENT array[20];
char username[50];
char password[50];
char option;
int slot;
int i;
for(i = 0; i < 20; i++)
{
array[i].stud_num = 0;
}
clrscr();
while(strcmp(username,"quit") != 0 || strcmp(password,"quit") != 0)
{
login(username, password);
for(slot = 0; slot < 20; slot++)
{
if(atoi(username) == array[slot].stud_num && atoi(password) == array[slot].stud_num)
break;
}
if(strcmp(username, "ADMIN") == 0 && strcmp(password, "admin") == 0)
{
option = '0';
while(option != 'x')
{
option = admin();
switch(option)
{
case '1' :
{
gotoxy(14,48); printf("Redirecting to [Add Student] Function --->...");
getche();
add_student(array);
break;
} //end of case '1'
case '2' :
{
gotoxy(14,48); printf("Redirecting to [Modify Student Account] Function --->...");
getche();
modify_student(array);
break;
} //end of case '2'
case '3' :
{
gotoxy(14,48); printf("Redirecting to [Delete Student Account] Function --->...");
getche();
delete_student(array);
break;
} //end of case '3'
case '4' :
{
gotoxy(14,48); printf("Redirecting to [Search Student Account] Function --->...");
getche();
search_student(array);
break;
} //end of case '4'
case '5' :
{
gotoxy(14,48); printf("Redirecting to [Display all Accounts] Function --->...");
getche();
display_students(array);
break;
} //end of case '5'
case '6' :
{
gotoxy(14,48); printf("Redirecting to [Delete all Accounts] Function --->...");
getche();
delete_all(array);
break;
} //end of case '6'
case '7' :
{
gotoxy(14,50); printf("Logging out...");
getche();
option = 'x';
break;
} //end of case '7'
case 'x' :
{ gotoxy(14,48); printf("Terminating Program...");
getche();
return 0;
} //end of case '8'
default :
{ printf("\n\nInvalid option");
} //end of default
} //end of switch
} //end of while(option != '6')
} //end of if
else if(atoi(username) == array[slot].stud_num && atoi(password) == array[slot].stud_num)
{
option = '0';
while(option != 'x')
{
option = student();
switch(option)
{
/*case '1' :
{
gotoxy(14,48); printf("Redirecting to [View Personal Profile] Function --->...");
getche();
view_account(array);
break;
} //end of case '1'
/*case '2' :
{
gotoxy(14,48); printf("Redirecting to [Modify Name] Function --->...");
getche();
modify_name(array);
break;
} //end of case '2'*/
/*case '3' :
{
gotoxy(14,48); printf("Redirecting to [Modify Birthdate] Function --->...");
getche();
modify_bday(array);
break;
} //end of case '3'*/
/*case '4' :
{
gotoxy(14,48); printf("Redirecting to [Modify Course] Function --->...");
getche();
modify_course(array);
break;
} //end of case '4'*/
case '5' :
{
gotoxy(14,50); printf("Logging out...");
getche();
option = 'x';
break;
} //end of case '5'
case 'x' :
{
gotoxy(14,50); printf("Terminating program...");
getche();
return 0;
} //end of case 'x'
default :
{ printf("\n\nInvalid option");
}
} //end of switch
} //end of while(option != 'x')
} //end of else if
else
{
if(strcmp(username,"quit") != 0 && strcmp(password,"quit") != 0)
{
gotoxy(19,30); printf("Invalid username or password.");
}
}
} //end of super big loop! XD haha
gotoxy(19,31); printf("Terminating Program...");
getche();
return 0;
}