The if statement inside the while loop is not working.
Code:
#include <stdio.h>
#include <string.h>
void startup_message();
int main ()
{
startup_message();
char username[10];
char correct_username[10];
char second_part_of_correct_username[5];
char firstname[10];
char lastname[20];
int attempts;
long long int cin;
long long int correct_password;
long long int password;
printf("Enter your first name:\n");
scanf("%s",firstname);
strncpy(correct_username,firstname,2);
correct_username[2]='\0';
printf("Enter your last name:\n");
scanf("%s",lastname);
strncpy(second_part_of_correct_username,lastname,3);
second_part_of_correct_username[3]='\0';
strncat(correct_username,second_part_of_correct_username,5);
printf("Enter your Customer Identification Number(CIN):\n");
scanf("%llu",&cin);
correct_password=(cin%10)+1;
printf("%d",correct_password);
printf("Enter username:\n");
scanf("%s",&username);
printf("Enter password:\n");
scanf("%llu",&password);
if ((password==correct_password) && strcmp(username,correct_username)==0)
{
printf("Login successful!\n");
}
while ((password!=correct_password) || strcmp(username,correct_username)!=0)
{
printf("Login unsucessful! Please try again.\n");
printf("Enter username:\n");
scanf("%s",&username);
printf("Enter password:\n");
scanf("%llu",&password);
++attempts;
if (attempts==5)
printf("Too many tries.\n");
if (attempts==5)
break;
}
return 0;
}
void startup_message()
{
printf("Welcome to the newly introduced smsTransfer (a joint project of STARTRIGHT AND GLOBE TELECOM)!\n\n");
printf("REMINDER: Both the transferers and the transferees must have active accounts with both companies to take part in this service.\n\n");
}