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();
}

bump???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.