This repository has been archived on 2023-10-26. You can view files and clone it, but cannot push or open issues or pull requests.
VSMechatronics/Lectures/LC7/Getch/getch.c

29 lines
608 B
C
Raw Permalink Normal View History

2022-04-07 15:58:01 +00:00
/*
Chapter 7: example of getch
This program reads a single keystroke and displays it
on the screen
*/
#include <stdio.h> /* Standard include files */
#include <stdlib.h>
#include <conio.h>
int main(void)
{
char x; /* Define a variable of type char */
printf("Input a character: ");
2022-04-07 15:58:01 +00:00
x = getch(); /* Use getchar to read a keypress and store the */
/* result in 'x' */
printf("\nDisplaying the char with putchar: ");
2022-04-07 15:58:01 +00:00
putchar(x); /* Display the character stored in 'x' on the */
/* screen using putchar */
return 0;
}