In the next code:
#include
int main(void) {
int c;
while ((c=getchar())!= EOF)
putchar(c);
return 0;
}
This code worked for me. Attention : this is not part of the standard library, even if most compilers (I use GCC) supports it.
#include
#include
int main(int argc, char const *argv[]) {
char a = getch();
printf("You typed a char with an ASCII value of %d, printable as '%c'\n", a, a);
return 0;
}
This code detects the first key press.