std::basic_istream::tellg(3)
πΈ std::basic_istream::tellg πΈ
okay so this is the page for std::basic_istream::tellg, straight outta the C++ Standard Libary manual (yes, that spelling, periodt π
). Itβs basically your input streamβs βwhere are we rn?β button, and honestly? iconic. π«Ά
β¨ NAME β¨
std::basic_istream::tellg β thatβs the whole name, bestie, no cap. This is the C++ Standard Libary manual page for it, and itβs giving βget-pointer gossip reporterβ energy. π
π¦ Synopsis π¦
pos_type tellg();
So hereβs the vibe: tellg() returns the input position indicator of the current associated streambuf object. It behaves as an UnformattedInputFunction, except that gcount() is not affected. After constructing and checking the sentry object, if fail() == true, it returns pos_type(-1). Otherwise, it returns rdbuf()->pubseekoff(0, std::ios_base::cur, std::ios_base::in). Slay. π
π Parameters π
- none β literally zero parameters, bestie. Zilch. Nada. π
π Return value π
- On success: the current position of the get pointer β¨
- On failure:
pos_type(-1)π
π₯ Exceptions π₯
- Throws
failureif an error occurred (the error state flag is notgoodbit) andexceptions()is set to throw for that state. π - If an internal operation throws an exception, it is caught and
badbitis set. Ifexceptions()is set forbadbit, the exception is rethrown. π¨
π Example π
Run this code, bestie:
#include <iostream>
#include <sstream>
#include <string>
int main()
{
std::string str = "Hello, world";
std::istringstream in(str);
std::string word;
in >> word;
std::cout << "After reading the word \"" << word
<< "\" tellg() returns " << in.tellg() << '\n';
}
π Output π
After reading the word "Hello," tellg() returns 6
π See also π
seekoffβ repositions the file position, using relative addressing[virtual](virtual protected member function ofstd::basic_filebuf<CharT,Traits>)seekoffβ repositions the next pointer in the input sequence, output sequence, or both, using relative addressing[virtual](virtual protected member function ofstd::basic_stringbuf<CharT,Traits,Allocator>)seekoffβ repositions the next pointer in the input sequence, output sequence, or both, using relative addressing[virtual](virtual protected member function ofstd::strstreambuf)seekgβ sets the input position indicator (public member function)tellpβ returns the output position indicator (public member function ofstd::basic_ostream<CharT,Traits>)seekpβ sets the output position indicator (public member function ofstd::basic_ostream<CharT,Traits>)
okay thatβs the whole page, bestie π«Ά β source/version: http://cppreference.com β’ date: 2024.06.10. Catch u later, mwah π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms