Character Input and Character Output - C Data Type

C examples for Data Type:char

Introduction

You can read a single character using the scanf() function with the format specifier %c.

To write a single character to the command line with the printf() function, use the format specifier, %c.

Demo Code

#include <stdio.h> 
  
int main(void) 
{ 
    char ch = 0;/* www.ja  va 2s  .  c om*/
    scanf("%c", &ch);                           // Read one character
    
    printf("The character is %c\n", ch);

    return 0; 
}

Result


Related Tutorials