std::strstream::pcount
來自 cppreference.com
int pcount() const; |
(C++98 起棄用) (C++26 中移除) |
|
返回關聯的 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 的公有成員函式) |