VOOZH about

URL: https://www.geeksforgeeks.org/cpp/basic_istreamputback-in-c-with-examples/

⇱ basic_istream::putback() in C++ with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

basic_istream::putback() in C++ with Examples

Last Updated : 15 Jul, 2025
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:
Output:
BOOD
putback is failed here
GOOD
Reference: https://cplusplus.com/reference/istream/istream/putback/
Comment
Article Tags: