Use scanf() to read the keyboard for a single character, specified by the placeholder %c. - C Data Type

C examples for Data Type:char

Description

Use scanf() to read the keyboard for a single character, specified by the placeholder %c.

Demo Code

#include <stdio.h>
int main()// w  ww . j  a v  a 2  s  . c  o  m
{
   char key;
   puts("Type your favorite keyboard character:");
   scanf("%c",&key);
   printf("Your favorite character is %c!\n",key);
   return(0);
}

Result


Related Tutorials