std::basic_ostream<CharT,Traits>::tellp
Von cppreference.com
< cpp | io | basic ostream
| pos_type tellp(); |
||
Gibt den Ausgabepositionsindikator des aktuell zugeordneten streambuf-Objekts zurück.
|
Verhält sich wie eine UnformattedOutputFunction (außer dass tatsächlich keine Ausgabe durchgeführt wird). Nach dem Erstellen und Überprüfen des Sentry-Objekts, |
(seit C++11) |
Wenn fail()==true, gibt pos_type(-1) zurück. Andernfalls gibt es rdbuf()->pubseekoff(0, std::ios_base::cur, std::ios_base::out) zurück.
Inhalt |
[edit] Parameter
(keine)
[edit] Rückgabewert
aktueller Ausgabepositionsindikator bei Erfolg, pos_type(-1) bei einem Fehler.
[edit] Beispiel
Führen Sie diesen Code aus
#include <iostream> #include <sstream> int main() { std::ostringstream s; std::cout << s.tellp() << '\n'; s << 'h'; std::cout << s.tellp() << '\n'; s << "ello, world "; std::cout << s.tellp() << '\n'; s << 3.14 << '\n'; std::cout << s.tellp() << '\n' << s.str(); }
Ausgabe
0 1 13 18 hello, world 3.14
[edit] Siehe auch
| setzt den Ausgabepositionsindikator (public member function) | |
| gibt den Eingabepositionsindikator zurück (public member function of std::basic_istream<CharT,Traits>) | |
| setzt den Eingabepositionsindikator (public member function of std::basic_istream<CharT,Traits>) |