I have a problem with my code, I want the code to check if the name
is equal to the realname
and print what's inside of the if
statement, otherwise, to print what's inside of the else
statement, at the end of the code it says what it throws.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
char name[5];
char realname[] = "Mike";
printf("Please, enter your name: ");
fgets(name, sizeof(name), stdin);
scanf(name, realname);
if (strcmp(name, realname))
{
printf("Nice to meet you %s ", name );
printf("I'm known as robot. ");
printf("And welcome to starting.com");
}
else
{
printf("You're not the owner of this account.");
}
}
//If i type "john" it returns this.
//Please, enter your name: john
//Nice to meet you john I'm known as machinecode. And welcome to starting.com
Aucun commentaire:
Enregistrer un commentaire