The std::ifstream::putback() function in C++ is a member function of the ifstream class that moves the stream read position one character back. It is used to re-read the last read character from the input stream.
Example:
```c++
#include
#include
int main()
{
std::ifstream inputFile("example.txt");
char c;
// read and print first character
inputFile.get(c);
std::cout << c << std::endl;
// move stream position back and read again
inputFile.putback(c);
inputFile.get(c);
std::cout << c << std::endl;
return 0;
}
```
In this example, the putback() function is used to re-read the first character of the input file after it has been read and printed to the console.
Package/Library: The putback() function is part of the standard C++ library and is included in the header file.
C++ (Cpp) ifstream::putback - 18 examples found. These are the top rated real world C++ (Cpp) examples of std::ifstream::putback extracted from open source projects. You can rate examples to help us improve the quality of examples.