Mail Archives: djgpp/1998/03/12/22:15:35
shifter wrote:
>
> #include <stdio.h>
>
> main()
> {
> char *i;
> char *password;
OOPS----^^^^^^^^
password is a pointer but points to nothing.
char *password = "xxxxxxxxxxxxxxxxxx"; works...
>
> clrscr();
> printf ("Input a password:");
> gets(password);
OOPS------^^^^^^^^
password must be allocated. With my version of initialization
it will work (password shorter then number of x's).
> printf("you typed:%s\n",password);
> do{
> printf ("Input a password:%s:",i);
> }while (gets(i) != password);
OOPS--------------^
Same problem for i.
OOPS---------^^^^^^^^^^^^^^^^^^^
Comparing strings doesn't work this way in C.
Should be "strcmp(gets(i), password)"
> printf("you got it!!!");
> exit(0);
> }
>
> i'm trying to get it to break out of loop with the correct password
> what am i doing wrong?
> ralph <shifter AT sainet DOT net>
greetings
- Raw text -