std::basic_stringstream::str
De cppreference.com
< cpp | io | basic stringstream
![]() |
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. |
std::basic_string<CharT,Traits,Allocator> str() const; |
(1) | |
void str(const std::basic_string<CharT,Traits,Allocator>& new_str); |
(2) | |
Administra el contenido del objeto de cadena subyacente .
1) Original:
Manages the contents of the underlying string object.
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.
Devuelve una copia de la cadena subyacente como si se aplicase rdbuf()->str() .
2) Original:
Returns a copy of the underlying string as if by calling rdbuf()->str().
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.
Reemplaza el contenido de la cadena subyacente como si se aplicase rdbuf()->str(new_str) .
Original:
Replaces the contents of the underlying string as if by calling rdbuf()->str(new_str).
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.
Contenido |
[editar] Parámetros
new_str | - | nuevos contenidos de la cadena subyacente
Original: new contents of the underlying string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[editar] Valor de retorno
1)una copia del objeto cadena subyacente .
2) Original:
a copy of the underlying string object.
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.
(Ninguno)
Original:
(none)
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.
[editar] Ejemplo
#include <sstream> #include <iostream> int main() { int n; std::istringstream in; // could also use in("1 2") in.str("1 2"); in >> n; std::cout << "after reading the first int from \"1 2\", the int is " << n << ", str() = \"" << in.str() << "\"\n"; std::ostringstream out("1 2"); out << 3; std::cout << "after writing the int '3' to output stream \"1 2\"" << ", str() = \"" << out.str() << "\"\n"; std::ostringstream ate("1 2", std::ios_base::ate); ate << 3; std::cout << "after writing the int '3' to append stream \"1 2\"" << ", str() = \"" << ate.str() << "\"\n"; }
Output:
after reading the first int from "1 2", the int is 1, str() = "1 2" after writing the int '3' to output stream "1 2", str() = "3 2" after writing the int '3' to append stream "1 2", str() = "1 23"
[editar] Ver también
o reemplaza obtiene una copia de la cadena de caracteres asociada Original: replaces or obtains a copy of the associated character string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público of std::basic_stringbuf función)
|