basic_istream--unget() in C++The basic_istream::unget() function is used to unget the character, which also decreases the location by a single character and allows the retrieved character to be reused. The appropriate header file should be provided. The objective of using the basic_istream::unget() method is to return a character to the stream, allowing it to be easily processed at a later stage. This function can lower the location by one character, essentially restoring the previously removed character. Header File:It included the <iostream> header file. Syntax: It has the following syntax: Parameters: The basic_istream::unget() function takes no parameters. Return value: The basic_istream object is returned by the method basic_istream::unget(). The following programs explain std::basic_istream::unget():Example:Filename: Ungetting1.cpp Output: We got: P After the ungetting, the character is: P Example 2:Filename: Ungetting2.cpp Output: We got: L After the ungetting, the character is: L Explanation:
Within the if block:
|