std::basic_ostream::put
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody> basic_ostream& put( char_type ch ); |
||
Écrit
ch caractère dans le flux de sortie .Original:
Writes character
ch to the output stream.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Cette fonction est une fonction de sortie non formatée: il commencer l'exécution par la construction d'un objet de
sentry type, qui vide les tampons de sortie tie()'d si nécessaire et vérifie les erreurs de flux. Après la construction, si les rendements objet sentinelle false, la fonction retourne sans tenter aucune sortie. Si une exception est levée lors de la sortie, puis ios :: BadBit est activé (l'exception est supprimée, sauf exceptions()&badbit) != 0, auquel cas il est relancée)Original:
This function is an unformatted output function: it begin execution by constructing an object of type
sentry, which flushes the tie()'d output buffers if necessary and checks the stream errors. After construction, if the sentry object returns false, the function returns without attempting any output. If an exception is thrown during output, then ios::badbit is set (the exception is suppressed unless exceptions()&badbit) != 0, in which case it is rethrown)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Paramètres
| ch | - | caractère à écrire
Original: character to write The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Retourne la valeur
*this
Notes
Cette fonction n'est pas surchargé pour les types
signed char ou unsigned char, contrairement à la << opérateur
formatéOriginal:
operator<<
The text has been machine-translated via [http://translate.google.com Google Translate].
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
Original:
This function is not overloaded for the types
signed char or unsigned char, unlike the formatted << opérateur
Original:
operator<<
The text has been machine-translated via [http://translate.google.com Google Translate].
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Contrairement aux fonctions de sortie formatée, cette fonction ne définit pas le
failbit si la sortie ne .Original:
Unlike formatted output functions, this function does not set the
failbit if the output fails.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Exemple
#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';
}
Résultat :
a
Unformatted output: fail=0 bad=1
Formatted output: fail=1 bad=1
Voir aussi
insère des données de caractères Original: inserts character data The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) | |
blocs inserts de caractères Original: inserts blocks of characters The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) | |