#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char username[12] = "admin";
char password[12] = "admin";
system("color 9f");
system("cls");
login:
printf(" ---------------------------------- \n");
printf(" | |\n");
printf(" | WELCOME TO OMAR WATER'S |\n");
printf(" | INVENTORY |\n");
printf(" | SYSTEM |\n");
printf(" | |\n");
printf(" ---------------------------------- \n\n\n");
printf("Please Log-In...\n\n");
printf("Username: ");
scanf("%c", &username);
if (username == "admin"){
printf("\nPassword: ");
scanf("%c", &password);
if (password == "admin"){
printf("\n\nWELCOME ", &username);
}else{
printf("INVALID PASSWORD");
getchar();
system("cls");
goto login;
}
}else {
printf("INVALID USERNAME");
getchar();
system("cls");
goto login;
}
getch();
return 0;
}
console application; c (not c++);
I am currently in the part of my program where I want to ask for a preset username and password. When I enter the correct username, instead of asking for the password, it just flashes the 'enter password' and jumps directly to the else statement. and then does the goto login; code.
Can anyone point me to the right direction on how to make this work? By the way, I am using dev-c++ IDE.