How char variables can be both integers and characters. - C Data Type

C examples for Data Type:char

Description

How char variables can be both integers and characters.

Demo Code

#include <stdio.h>
int main()/*from w  w  w.ja  v  a 2s . c  om*/
{
   char key;
   printf("Press a key on your keyboard:");
   key=getchar();
   printf("You pressed the '%c' key.\n",key);
   printf("Its ASCII value is %d.\n",key);
   return(0);
}

Result


Related Tutorials