The
basic_istream::putback() used to put the character back in the input string. This function is present in the
iostream header file. Below is the syntax for the same:
Header File:
#include<iostream>
Syntax:
basic_istream& putback (char_type ch);
Parameter:
- ch: It represents the character to be put into the input string back.
Return Value: The
iostream::basic_istream::putback() return the basic_istream object.
Below are the programs to understand the implementation of
std::basic_istream::putback() in a better way:
Program 1:
Output:
AeeksforGeeks
putback is failed here
GeeksforGeeks
Program 2: