-
help plz i cant do it :(
the simple program below increments numbers until a key on the keyboard is hit. I want the program to increment numbers while a key is pressed down by the user and to stop incrementing the numbers when the key (being the space bar) is no longer pressed down. please can someone help me out as im not sure how thats done.....thanks :)
Code:
#include <conio.h>
#include <stdio.h>
int main (void)
{
int sale;
sale = 000.00;
do{
clrscr();
printf("%d", sale);
delay(150);
sale += 0.01;
}while(!kbhit());
return 0;
}
-
i sussed it out!!!!!!!! :):) it took two days and all i needed was one line :| just posting it up here cos it mite help someone else? :) bye!!! fizz -x-
Code:
#include <conio.h>
#include <stdio.h>
int main (void)
{
float sale;
int key;
sale = 000.00;
while(!kbhit()){
clrscr();
key=getch();
while( getch()!='\n'){
clrscr();
printf("%3.2f", sale);
delay(150);
sale += 0.01;
}
}
return 0;
}
-