std::basic_istream::tellg
Материал из cppreference.com
|
|
Эта страница была переведена автоматически с английской версии вики используя Переводчик Google. Перевод может содержать ошибки и странные формулировки. Наведите курсор на текст, чтобы увидеть оригинал. Щёлкните здесь, чтобы увидеть английскую версию этой страницы. (Вы можете помочь в исправлении ошибок и улучшении перевода. Для инструкций перейдите по ссылке.) |
<metanoindex/>
<tbody> </tbody> pos_type tellg(); |
||
Returns input position indicator of the current associated streambuf object.
Behaves as UnformattedInputFunction. After constructing and checking the sentry object, if fail()==true, returns pos_type(-1). Otherwise, returns rdbuf()->pubseekoff(0, std::ios_base::cur, std::ios_base::in).
Параметры
(Нет)
Возвращаемое значение
current position of the get pointer on success, pos_type(-1) on failure
Пример
Запустить этот код
#include <iostream>
#include <string>
#include <sstream>
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';
}
Вывод:
After reading the word "Hello," tellg() returns 6
См. также
| устанавливает указатель позиции ввода (public функция-элемент) | |
| возвращает указатель позиции вывода (public функция-элемент std::basic_ostream)
| |
| устанавливает указатель позиции вывода (public функция-элемент std::basic_ostream)
|