std::basic_ostream<CharT,Traits>::put (3) - Linux Manuals
std::basic_ostream<CharT,Traits>::put: std::basic_ostream<CharT,Traits>::put
Command to display std::basic_ostream<CharT,Traits>::put
manual in Linux: $ man 3 std::basic_ostream<CharT,Traits>::put
NAME
std::basic_ostream<CharT,Traits>::put - std::basic_ostream<CharT,Traits>::put
Synopsis
basic_ostream& put( char_type ch );
Behaves as an UnformattedOutputFunction. After constructing and checking the sentry object, writes the character ch to the output stream.
If the output fails for any reason, sets badbit.
Parameters
ch - character to write
Return value
*this
Notes
This function is not overloaded for the types signed char or unsigned char, unlike the formatted operator<<
Unlike formatted output functions, this function does not set the failbit if the output fails.
Example
// Run this code
#include <fstream>
#include <iostream>
int main()
{
std::cout.put('a'); // normal usage
std::cout.put('\n');
std::ofstream s("/does/not/exist/");
s.clear(); // pretend the stream is good
std::cout << "Unformatted output: ";
s.put('c'); // this will set badbit, but not failbit
std::cout << " fail=" << bool(s.rdstate() & s.failbit);
std::cout << " bad=" << s.bad() << '\n';
s.clear();
std::cout << "Formatted output: ";
s << 'c'; // this will set badbit and failbit
std::cout << " fail=" << bool(s.rdstate() & s.failbit);
std::cout << " bad=" << s.bad() << '\n';
}
Output:
a
Unformatted output: fail=0 bad=1
Formatted output: fail=1 bad=1
See also
inserts character data
operator<<(std::basic_ostream) (function template)
inserts blocks of characters
write (public member function)
Pages related to std::basic_ostream<CharT,Traits>::put
- std::basic_ostream<CharT,Traits>::basic_ostream (3) - std::basic_ostream<CharT,Traits>::basic_ostream
- std::basic_ostream<CharT,Traits>::flush (3) - std::basic_ostream<CharT,Traits>::flush
- std::basic_ostream<CharT,Traits>::operator<< (3) - std::basic_ostream<CharT,Traits>::operator<<
- std::basic_ostream<CharT,Traits>::operator= (3) - std::basic_ostream<CharT,Traits>::operator=
- std::basic_ostream<CharT,Traits>::seekp (3) - std::basic_ostream<CharT,Traits>::seekp
- std::basic_ostream<CharT,Traits>::sentry (3) - std::basic_ostream<CharT,Traits>::sentry
- std::basic_ostream<CharT,Traits>::swap (3) - std::basic_ostream<CharT,Traits>::swap
- std::basic_ostream<CharT,Traits>::tellp (3) - std::basic_ostream<CharT,Traits>::tellp
- std::basic_ostream<CharT,Traits>::write (3) - std::basic_ostream<CharT,Traits>::write
- std::basic_ostream<CharT,Traits>::~basic_ostream (3) - std::basic_ostream<CharT,Traits>::~basic_ostream
- std::basic_ostream (3) - std::basic_ostream
- std::basic_ostream_sentry (3)
- std::basic_ostringstream (3) - std::basic_ostringstream
- std::basic_ostringstream::operator= (3) - std::basic_ostringstream::operator=
- std::basic_ostringstream::rdbuf (3) - std::basic_ostringstream::rdbuf
- std::basic_ostringstream::swap (3) - std::basic_ostringstream::swap
- std::basic_ostringstream<CharT,Traits,Allocator>::basic_ostringstream (3) - std::basic_ostringstream<CharT,Traits,Allocator>::basic_ostringstream
- std::basic_ostringstream<CharT,Traits,Allocator>::str (3) - std::basic_ostringstream<CharT,Traits,Allocator>::str
- std::basic_osyncstream (3) - std::basic_osyncstream