std::strstream::pcount
int pcount() const; |
Возвращает количество символов, выведенных в область вывода связанного std::strstreambuf. Эффективно вызывает rdbuf()->pcount().
Параметры
(нет)
Возвращаемое значение
Количество символов в области вывода или ноль, если ничего не было выведено.
Пример
#include <iostream>
#include <strstream>
int main()
{
std::strstream 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::strstream user(buf, 10); // user-provided output buffer
user << 1.23; // note: no 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) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/io/strstream/pcount