0

My question is when user enter any key from the keyboard including arrow keys, it should print one asterisk * , when user will again press any key it will add one more asterisk and ,and when user again press any key from keyboard it should add one more asterisk, so on...
when user will press backspace it should remove only one *
just like password writing...

my problem in my following code is that when i press any key from keyboard that has ascii value it is working fine.. but when i enter any key that has scan code like arrow keys or F1 F2 , F3.. it is printing two asterisk at one click..

[ im using BORLAND 5.02, That has clear screen function i.e clrscr(); ]

#include<iostream>
#include<conio.h>

void main()
{
clrscr();

int count=0;
int a,i,s,l;

for (;;)
{a=getch();


if(a!=8){
clrscr();

for (i=0;i<=count;i++)
{cout<<"*";}

count++;
}



if (a==8){
clrscr();
 if (count!=0){
count=count-1;}
 for(s=1;s<=1;) {

 for (l=0;l<count;l++)
 {cout<<"*";}
 break; }
 }}

getch();
}

Edited by AmerJamil: n/a

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by AmerJamil
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.