# std::ostrstream::pcount

> C++ Atlas: `cppatlas.com/w/cpp/io/ostrstream/pcount` | Source: https://en.cppreference.com/w/cpp/io/ostrstream/pcount | Domain: Input/output | Standards: C++26

Returns the number of characters that were output in the put area of the associated std::strstreambuf. Effectively calls rdbuf()->pcount().

## Official Specification Summary (cppreference)

```cpp
int pcount() const; // (deprecated in C++98) (removed in C++26)
```

Returns the number of characters that were output in the put area of the associated `std::strstreambuf`. Effectively calls `rdbuf()->pcount()`.

### Parameters

(none)

### Return value

The number of characters in the put area, or zero if nothing was output.

### Example

```cpp
#include <iostream>
#include <strstream>

int main()
{
    std::ostrstream dyn; // dynamically-allocated output buffer
    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-provided output buffer
    user << 1.23; // note: no std::ends
    std::cout.write(buf, user.pcount());
    std::cout << '\n';
}
```

Output:

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

### See also

- [`pcount`](https://en.cppreference.com/w/cpp/io/strstreambuf/pcount): returns the next pointer minus the beginning pointer in the output sequence: the number of characters written (public member function of `std::strstreambuf`)

---
Attribution: content from https://en.cppreference.com/w/cpp/io/ostrstream/pcount (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.