std::ios_base:: seekdir
From cppreference.net
|
typedef
/*implementation defined*/
seekdir
;
|
||
|
static
constexpr
seekdir beg
=
/*implementation defined*/
static
constexpr
seekdir end
=
/*implementation defined*/
|
||
Gibt den Typ der Dateipositionierungsrichtung an. Die folgenden Konstanten sind definiert:
| Konstante | Erklärung |
| beg | der Anfang eines Streams |
| end | das Ende eines Streams |
| cur | die aktuelle Position des Stream-Positionsindikators |
Beispiel
Diesen Code ausführen
#include <iostream> #include <sstream> #include <string> int main() { std::istringstream in("Hello, World!"); std::string word1, word2, word3, word4, word5; in >> word1; in.seekg(0, std::ios_base::beg); // <- zurückspulen in >> word2; in.seekg(1, std::ios_base::cur); // -> von aktueller Position zum Ende suchen in >> word3; in.seekg(-6, std::ios_base::cur); // <- von aktueller Position (Ende) zum Anfang suchen in >> word4; in.seekg(-6, std::ios_base::end); // <- vom Ende zum Anfang suchen in >> word5; std::cout << "word1 = " << word1 << '\n' << "word2 = " << word2 << '\n' << "word3 = " << word3 << '\n' << "word4 = " << word4 << '\n' << "word5 = " << word5 << '\n'; }
Ausgabe:
word1 = Hello, word2 = Hello, word3 = World! word4 = World! word5 = World!
Siehe auch
|
setzt die Eingabepositionsanzeige
(öffentliche Elementfunktion von
std::basic_istream<CharT,Traits>
)
|
|
|
setzt die Ausgabepositionsanzeige
(öffentliche Elementfunktion von
std::basic_ostream<CharT,Traits>
)
|
|
|
ruft
seekoff
(
)
auf
(öffentliche Elementfunktion von
std::basic_streambuf<CharT,Traits>
)
|