eof(), ignore(), peek(), putback(), flush(), tellg(), tellp() functions in C++

eof() function: It is used to find whether the end of file is reached. It returns true when end of file is reached, otherwise it returns false. Syntax of eof() function:

bool eof( );

ignore() function: It is used to read and remove characters from a input stream.

Syntax of ignore() function:

istream &ignore(streamsize num=1, int_type delimiter=EOF);

Here, characters are read and ignored until num or until delimiter is encountered.

peek() function: It is used to get next character in input stream without removing that particular character from the input stream.

Syntax of peek() function:

int_type peek( );

putback() function: It is used to return the last character which was read from the stream to the same stream.

Syntax of putback() function:

istream &putback(char c);

flush() function: It is used to flush all the internal buffers linked to the stream.

Syntax of flush() function:

ostream &flush( );

tellg() and tellp() functions: These functions are used to get the current position of a file pointer.

Syntax of tellg() function:

position_type tellg( );

Syntax of tellp() function:

position_type tellp( );

Leave a Reply