Hi! So I was playing with command line arguments to get used to work with them. I tried to make the program to say valid if the argument I would write is the same as the one saved in the variable. Any ideas why this doesn't work?
CodePudding user response:
Use strcmp
to compare strings.
In C, you cannot use ==
and !=
to check for string equality.
What you want is:
if (strcmp(argv[1], pass)) // Use String Compare (strcmp) to test equality.
// Returns 0 if strings are equal
// Returns non-zero if strings are different.
{
printf("Invalid\n");
}