So I'm very new to programming and i have to make a code that asks the user their firs name and last name, and then to create a password with at least 3 characters and one uppercase letter and I'm very lost, my code has many issues and i don't think it makes a whole lot of sense, here it is:
#include <stdio.h>
#include <string.h>
int main()
{
char name[20], last_name[20];
printf("Please, enter your name and last name:\n");
printf("Name: ");
scanf("%s", name);
printf("Last name: ");
scanf("%s", last_name);
char userInput[64];
char pass = 0;
char password[25];
int i;
int x;
size_t length = 0;
while( pass == 0 ) {
length = 0;
pass = 0;
printf("\nPlease, create a password:\n ");
fgets(userInput, 63, stdin);
length = strlen(userInput);
if( length < 4) {
printf("The password must have at least 3 characters\n");
continue;
}
scanf(" %s", password);
for (i = 0; i < 25; i++) {
if (isupper(password[i])) {
break;
}
else if (password[i] == '\0') {
printf("\nPlease, enter at least one uppercase letter\n");
break;
}
}
}
return 0;
}
the "Please, enter your name and last name" repeats itself the first time it appears and i don't know why, and when the password doesn't have an uppercase it doesn't ask the user to create a new password, how can i fix any of this?
any help is much appreciated