Hi all!
I'm a novice with C programming and i have to solve an error in the following code. The code works like you enter a password called "uoc"
and it shows as OK. But surprisely when you entered another password as "Cambridge" it works fine too.
I think that the problem is in the array declaration but i'm checking resources and no success!
Any tip?
Thanks so much!
Please find the code:
Code:
#include <stdio.h>
#include <string.h>
struct {
char str[8];
char ok;
} data;
int main(int argc, char *argv[])
{
data.ok = 0;
while (data.ok == 0)
{
printf("Passwd? ");
scanf("%s", data.str);
if (strcmp(data.str, "uoc")==0) data.ok = 1;
}
printf("Passwd OK\n");
return(0);
}