Press any key to exit: kbhit() : Console Read Any « Console « C / ANSI-C






Press any key to exit: kbhit()

Press any key to exit: kbhit()
  
#include <stdio.h>
#include <conio.h>

int main(void)
{
  double amount;

  amount = 0.20;

  cprintf("Printing 5-percent tax table\n\r");
  cprintf("Press a key to stop.\n\n\r");
 
  do {
    cprintf("amount: %f, tax: %f\n\r", amount, amount * 0.05);
 
    if(kbhit()) 
        break;
 
    amount = amount + 0.20;
 
  } while(amount < 100.0);

  return 0;
}


           
       








Related examples in the same category

1.Get char from the console