- #1
Akshay_Anti
- 62
- 0
Hello there!
I typed this code and saved it as a .c file
This code displays ASCII value of any character entered... The problem is that it being an infinite loop does not exit itself on pressing escape key.. How to handle that exception?
And what is the equivalent of kbhit() in C++ and in which header?
Thanks in advance
I typed this code and saved it as a .c file
Code:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int main()
{
int a;
while(1)
{
if (kbhit())
{
system("cls");
printf("%d ",getche());
}
}
return 0;
getch();
}
This code displays ASCII value of any character entered... The problem is that it being an infinite loop does not exit itself on pressing escape key.. How to handle that exception?
And what is the equivalent of kbhit() in C++ and in which header?
Thanks in advance