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/Exercises/C7/Getchar/getchar_example.c

20 lines
390 B
C
Raw Permalink Normal View History

2022-04-08 15:12:38 +00:00
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
// declare variable
char c;
printf("Input a character: ");
2022-04-08 15:12:38 +00:00
// Wait for a kepypress, store result in c
c = getchar();
// Display on the screen using printf
printf ("The charcter pressed was %c\n", c);
// Display the charcter using putchar()
putchar(c);
return 0; // Exit from main
}