int_type putback (char_type c);
#includeusing namespace std; int main() { char ch; cin.get(ch); cout<
This code reads a character from the input stream using cin.get(), prints it to the console, puts the character back into the input buffer using cin.putback(), reads the same character again using cin.get(), and prints it to the console.
Example 2:#include#include using namespace std; int main() { ifstream inputFile; inputFile.open("example.txt"); char ch; while (inputFile.get(ch)) { if (ch == ' ') { inputFile.putback(ch); cout< This code reads a file called "example.txt" and prints each character to the console. If the character is a space, it puts the space back into the input buffer using inputFile.putback() and prints a message to the console indicating that the character was put back. This code requires the fstream package library to be included. In conclusion, the std istream putback() function is a useful tool for manipulating the input buffer of an input stream in C++. It can be used to read and manipulate characters from files, user input, and other sources of input. The function is part of the C++ standard library and is available in all standard C++ environments.