getchar() putchar() : C-Style character level console I/O functions – CSKC
Sign In

Search

Code Learning #CPP#2155    siteicon   siteicon  

getchar() putchar() : C-Style character level console I/O functions

The functions which are frequently used in C, getchar() and putchar() provide a feature of character level console input and output facility.

Learning Objectives

  • Understanding concept of unformatted console I/O using the c-style functions like getchar() and putchar() in c++.

Source Code

TC++ #2155

Source Code

×

Ask AI About This Code

Default Prompt that is passed along with the code is given below, You can write your own prompt if you so desire.



×

Test CPP

Code Understanding

#include <stdio.h>
This header inclusion is required for c-style console I/O functions.

c=getchar();
Console waits for a character to be inputted and as soon as enter is pressed, the character entered by user is filled into the returned variable which is c in this example.

putchar(c);
This function outputs the given character which is passed as its parameter.

Notes

  • Use of getchar() and putchar() can be totally avoided in c++. It is retained so that old style programming code modules can still be used in c++.
  • Sometimes getchar() may find use in applications where screen has to wait for user to press a key.


Suggested Filename(s): getputchar.cpp



Share

Created: 4-Jan-2018 01:03 | Updated: 4-Jan-2018 01:03|