Namespaces
Variants

std::basic_ostream<CharT,Traits>:: tellp

From cppreference.net
pos_type tellp ( ) ;

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

UnformattedOutputFunction 처럼 동작합니다(실제 출력을 수행하지 않는다는 점을 제외하고). sentry 객체를 구성하고 검사한 후,

(since C++11)

만약 fail ( ) == true 인 경우, pos_type ( - 1 ) 를 반환합니다. 그렇지 않으면, rdbuf ( ) - > pubseekoff ( 0 , std:: ios_base :: cur , std:: ios_base :: out ) 를 반환합니다.

목차

매개변수

(없음)

반환값

성공 시 현재 출력 위치 표시자, pos_type ( - 1 ) 실패 시 반환됩니다.

예제

#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();
}

출력:

0
1
13
18
hello, world 3.14

참고 항목

출력 위치 표시자를 설정함
(public member function)
입력 위치 표시자를 반환함
( std::basic_istream<CharT,Traits> 의 public member function)
입력 위치 표시자를 설정함
( std::basic_istream<CharT,Traits> 의 public member function)