Newsgroups: comp.os.msdos.djgpp From: "A. Jans-Beken" Subject: Re: why don't this work Content-Type: text/plain; charset=us-ascii Message-ID: <350818AA.7A9D@oce.nl> Sender: news AT oce DOT nl (The Daily News @ nntp01.oce.nl) Content-Transfer-Encoding: 7bit Organization: Océ-Nederland B.V. References: <34F79C17 DOT 71DC AT sainet DOT net> Mime-Version: 1.0 Date: Thu, 12 Mar 1998 17:17:30 GMT Lines: 42 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk shifter wrote: > > #include > > 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 greetings