1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
// istringstream::rdbuf
#include <string> // std::string
#include <iostream> // std::cout
#include <sstream> // std::istringstream, std::stringbuf
int main () {
std::istringstream iss;
std::stringbuf *pbuf = iss.rdbuf();
// using stringbuf directly:
pbuf->str("Example string");
int size = pbuf->in_avail();
while (pbuf->in_avail()>0)
std::cout << static_cast<char>(pbuf->sbumpc());
return 0;
}
|