Mail Archives: djgpp/1998/03/03/05:17:18
Doesn't work because you're comparing pointers, not contents of. You need to use the strcmp() function, ie,
while(strcmp(gets(i),password))
Hm... You may also have a buffer problem just declaring i and password as char pointers, but maybe not.
In message <34F79C17 DOT 71DC AT sainet DOT net>, shifter <shifter AT sainet DOT net> wrote:
> #include <stdio.h>
>
> main()
> {
> char *i;
> char *password;
>
> clrscr();
> printf ("Input a password:");
> gets(password);
> printf("you typed:%s\n",password);
> do{
> printf ("Input a password:%s:",i);
> }while (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>
>
- Raw text -