GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::basic_ostream::put(3) C++ Standard Libary std::basic_ostream::put(3)

std::basic_ostream::put - std::basic_ostream::put


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.


ch - character to write


*this


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.

// 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';
}


a
Unformatted output: fail=0 bad=1
Formatted output: fail=1 bad=1


operator<<(std::basic_ostream) inserts character data or insert into rvalue stream
(function template)
write inserts blocks of characters
(public member function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.