Read characters from keyboard input and send them to the screen with getchar() and putchar() - C Data Type

C examples for Data Type:char

Introduction

This process is called echoing the input.

It uses a while loop that terminates when the # character is encountered.

Demo Code

           
#include <stdio.h>
int main(void)
{
    char ch;/* w w  w.ja va  2 s .  c o m*/
    
    while ((ch = getchar()) != '#')
        putchar(ch);
    
    return 0;
}

Result


Related Tutorials