www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/13/13:15:57

From: Sergey Kirpa <kirpa AT zfs DOT lg DOT ua>
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
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp


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



- Raw text -


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