From: Chris Doty Newsgroups: comp.os.msdos.djgpp Subject: Re: why don't this work Date: Sat, 28 Feb 1998 03:08:52 -0800 Organization: Worcester Polytechnic Institute Lines: 33 Message-ID: <34F7F044.7F52@atticus.com> References: <34F79C17 DOT 71DC AT sainet DOT net> NNTP-Posting-Host: orz.res.wpi.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk You're comparing the address of the strings, not the content of the strings. Use strcmp. Replace this line: }while (gets(i) != password); with this: }while (!strcmp(gets(i), password)); In C strings are arrays of characters, and arrays are pointers. Net result: strings are pointers. If you say string1 = string2; and then say string1[0] = 'a'; you'll find that string2s first character is now also 'a'. shifter wrote: > > #include > > 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