From: Sergey Kirpa Newsgroups: comp.os.msdos.djgpp Subject: Re: Why doesn't this work? Date: Wed, 13 May 1998 08:51:28 +0300 Organization: Lucky Net Ltd. Lines: 68 Message-ID: <355934E0.9476EBD4@zfs.lg.ua> References: <001101bd7ded$f8a31380$a74e08c3 AT arthur> Reply-To: kirpa AT zfs DOT lg DOT ua NNTP-Posting-Host: zfs.lg.ua Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Content-Transfer-Encoding: 8bit Precedence: bulk Arthur wrote: > Found a simple password program in QBASIC and as an exercise tried to > convert it to C. So simple, you may say. It is, but for the life of me I > could not get printf (of all things) to work. > > Source attached. > > char password(void) > { > char letter[5],count; (1) --------------^ > > printf("\n\n Please enter your password: "); > > for (count=0;count<5;count++) (2) -----------------------^ > { > while (kbhit()!=0); > > letter[count]=getch(); > printf("*"); > > } > > letter[5]='\0'; (3) ------------^ > > return (!strcmp(letter,"hello")); (4) ------------------------------^ >} ------------------------ 0 | 1 | 2 | 3 | 4 | 5 | ------------------------ h | e | l | l | o | \0 | ------------------------ = 6 bytes !!! ;( You may use "char letter [6];" in (1) case. -- ,,, (.~.) =========================--oOO--(_)--OOo--===================== ๋ษาะม ๓.้. kirpa AT zfs DOT lg DOT ua