=====get=====
Syntax:
int istream::get();
istream& istream::get( char& ch );
istream& istream::get( char* buffer, streamsize num );
istream& istream::get( char* buffer, streamsize num, char delim );
istream& istream::get( streambuf& buffer );
istream& istream::get( streambuf& buffer, char delim );
The get() function is used with input streams, and either:
* reads a character and returns that value,
* reads a character and stores it as ch,
* reads characters into buffer until num - 1 characters have been read, or EOF, or newline encountered, or the delim character encountered (delim is not read until next time),
* or reads characters into buffer until a newline, EOF, or delim character is encountered (again, delim isn't read until the next get() ).
For example, the following code displays the contents of a file called
temp.txt, character by character:
char ch;
ifstream fin( "temp.txt" );
while( fin.get(ch) )
cout << ch;
fin.close();
Related Topics: [[gcount]], [[getline]], [[/string/getline|(C++ Strings) getline]], [[ignore]], [[peek]], [[put]], [[read]]