Namespaces
Variants

std::strstreambuf:: pcount

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

출력 시퀀스에 기록된 문자 수를 반환합니다.

put 영역의 다음 포인터( std::streambuf::pptr() )가 널 포인터인 경우, 0을 반환합니다.

그렇지 않으면, put 영역의 다음 포인터에서 put 영역의 시작 포인터를 뺀 값을 반환합니다. 즉 pptr ( ) - pbase ( ) 입니다.

목차

매개변수

(없음)

반환값

put 영역에 기록된 문자 수입니다.

예제

#include <iostream>
#include <strstream>
int main()
{
    std::strstream dyn; // 동적으로 할당된 출력 버퍼
    dyn << "Test: " << 1.23 << std::ends;
    std::strstreambuf* buf = dyn.rdbuf();
    std::cout << "출력의 크기는 "
              << buf->pcount() // 또는 단순히 buf.pcount()
              << "이고, 내용은 \"" << dyn.str() << "\"\n";
    dyn.freeze(false); // 동적 strstream에서 .str() 호출 후
    char arr[10];
    std::ostrstream user(arr, 10); // 사용자 제공 출력 버퍼
    buf = user.rdbuf();
    user << 1.23; // 참고: std::ends 없음
    std::cout.write(arr, buf->pcount()); // 또는 단순히 user.pcount()
    std::cout << '\n';
    std::istrstream lit("1 2 3"); // 읽기 전용 고정 크기 버퍼
    buf = lit.rdbuf();
    // istrstream에는 pcount() 멤버 함수가 없으므로 lit.pcount()는 작동하지 않음
    std::cout << "입력 전용 pcount() = " << buf->pcount() << '\n';
}

출력:

출력의 크기는 11이고 내용은 "Test: 1.23"
1.23
입력 전용 pcount() = 0

참고 항목

작성된 문자 수를 얻음
( std::strstream public member function )
작성된 문자 수를 얻음
( std::ostrstream public member function )