delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/03/05:17:18

Date: Tue, 3 Mar 1998 05:16:56 -0500 (EST)
Message-Id: <199803031016.FAA26108@p2.acadia.net>
To: shifter <shifter AT sainet DOT net>
Subject: Re: why don't this work
Cc: djgpp AT delorie DOT com
References: <34F79C17 DOT 71DC AT sainet DOT net>
in-reply-to: <34F79C17.71DC@sainet.net>
From: swarnerx3 AT acadia DOT net (Scott Warner)
MIME-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019