Mail Archives: djgpp/1998/05/13/13:15:57
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 -