std::basic_ostream<CharT,Traits>::write
|
|
Esta página se ha traducido por ordenador/computador/computadora de la versión en inglés de la Wiki usando Google Translate.
La traducción puede contener errores y palabras aparatosas/incorrectas. Planea sobre el texto para ver la versión original. Puedes ayudar a corregir los errores y mejorar la traducción. Para instrucciones haz clic aquí. |
basic_ostream& write( const char_type* s, std::streamsize count ); |
||
Outputs characters from successive locations in the character array whose first element is pointed to by s. Characters are inserted into the output sequence until one of the following occurs:
- exactly
countcharacters are inserted - inserting into the output sequence fails (in which case
setstate(badbit)is called)
sentry, que vacía los buffers de salida tie()'d si es necesario y comprueba los errores de secuencia. Después de la construcción, si se devuelve el objeto centinela false, la función devuelve sin pretender ninguna salida. Si se produce una excepción durante la salida, entonces ios :: badbit se establece (se suprime la excepción a menos que exceptions()&badbit != 0, en cuyo caso se vuelve a iniciar)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)You can help to correct and verify the translation. Click here for instructions.
Parámetros
| s | - | pointer to the character string to write |
| count | - | number of characters to write |
Valor de retorno
*this
Notas
signed char o unsigned char, a diferencia del You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
signed char or unsigned char, unlike the formatted 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 here for instructions.
Also, unlike the formatted output functions, this function does not set the failbit on failure.
Excepciones
If an exception occurs during output and exceptions()&badbit != 0, rethrows that exception.
If output fails and exceptions()&badbit != 0, throws ios_base::failure.
Ejemplo
This function may be used to output object representations, i.e. binary output
#include <iostream>
int main()
{
int n = 0x41424344;
std::cout.write(reinterpret_cast<char*>(&n), sizeof n);
std::cout << '\n';
}
Salida:
DCBA
Ver también
| inserciones de datos caracter (función) | |
| Inserta un carácter. (función miembro pública) |