Namespaces
Variants

std::basic_istream<CharT,Traits>:: tellg

From cppreference.net
pos_type tellg ( ) ;

현재 연결된 streambuf 객체의 입력 위치 표시자를 반환합니다.

UnformattedInputFunction 처럼 동작하지만, gcount() 는 영향을 받지 않습니다. sentry 객체를 생성하고 검사한 후, fail ( ) == true 인 경우 pos_type ( - 1 ) 를 반환합니다. 그렇지 않으면 rdbuf ( ) - > pubseekoff ( 0 , std:: ios_base :: cur , std:: ios_base :: in ) 를 반환합니다.

목차

매개변수

(없음)

반환값

성공 시 get 포인터의 현재 위치, pos_type ( - 1 ) 실패 시.

예외

failure if an error occurred (the error state flag is not goodbit ) and exceptions() is set to throw for that state.

내부 연산에서 예외가 발생하면, 해당 예외는 포착되고 badbit 이 설정됩니다. 만약 exceptions() badbit 에 대해 설정되어 있다면, 예외가 다시 발생됩니다.

예제

#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';
}

출력:

After reading the word "Hello," tellg() returns 6

참고 항목

[virtual]
상대 주소 지정을 사용하여 파일 위치를 재배치함
( std::basic_filebuf<CharT,Traits> 의 virtual protected 멤버 함수)
[virtual]
상대 주소 지정을 사용하여 입력 시퀀스, 출력 시퀀스 또는 둘 모두의 다음 포인터를 재배치함
( std::basic_stringbuf<CharT,Traits,Allocator> 의 virtual protected 멤버 함수)
[virtual]
상대 주소 지정을 사용하여 입력 시퀀스, 출력 시퀀스 또는 둘 모두의 다음 포인터를 재배치함
( std::strstreambuf 의 virtual protected 멤버 함수)
입력 위치 표시자를 설정함
(public 멤버 함수)
출력 위치 표시자를 반환함
( std::basic_ostream<CharT,Traits> 의 public 멤버 함수)
출력 위치 표시자를 설정함
( std::basic_ostream<CharT,Traits> 의 public 멤버 함수)