#include <stdio.h>
#include <curses.h>
int main(int argc, char **argv)
{
int ch;
int gotCtlC = 0;
/* Put the terminal in raw mode - this avoids input processing */
initscr(); cbreak(); raw();
printf("This prints hexadecimal ascii codes of keys typed\r\n");
printf("To exit, hit Control-C twice in a row.\r\n"); fflush(stdout);
while ((ch = getch()) != EOF) {
if ((ch == '\r') || (ch == '\n'))
printf("\r\n");
printf(" %02X ", ch); fflush(stdout);
/* control-c twice in a row gets you out */
if (ch == 03) {
if (gotCtlC++) break;
}
else
gotCtlC = 0;
}
noraw();
nocbreak();
return 0;
}
Main Topics
Browse All Topics





by: ashwini_mohanPosted on 2004-08-15 at 13:59:05ID: 11805568
how can i get the ascii value of any key such as Enter key in c programming. i want this solution with sample program.