Namespaces
Variants

std::ostrstream:: pcount

From cppreference.net

int pcount ( ) const ;
(C++98에서 사용 중단됨)
(C++26에서 제거됨)

연관된 std:: strstreambuf 의 출력 영역(put area)에 출력된 문자 수를 반환합니다. 효과적으로 rdbuf ( ) - > pcount ( ) 를 호출합니다.

목차

매개변수

(없음)

반환값

출력 영역의 문자 수, 또는 출력된 내용이 없을 경우 0입니다.

예제

#include <iostream>
#include <strstream>
int main()
{
    std::ostrstream dyn; // 동적으로 할당된 출력 버퍼
    dyn << "Test: " << 1.23 << std::ends;
    std::cout << "The size of the output is " << dyn.pcount()
              << " and it holds \"" << dyn.str() << "\"\n";
    dyn.freeze(false);
    char buf[10];
    std::ostrstream user(buf, 10); // 사용자 제공 출력 버퍼
    user << 1.23; // 참고: std::ends 없음
    std::cout.write(buf, user.pcount());
    std::cout << '\n';
}

출력:

The size of the output is 11 and it holds "Test: 1.23"
1.23

참고 항목

출력 시퀀스에서 다음 포인터에서 시작 포인터를 뺀 값을 반환합니다: 기록된 문자 수
( std::strstreambuf 의 public 멤버 함수)