How to use ostrstream with dynamic buffer in C++

1 Answer

0 votes
#include <iostream>
#include <strstream>  

using std::cout;
using std::endl;

int main()
{
	char *p;

	std::ostrstream os;

	os << "C++ Programming" << endl;
	os.setf(std::ios::showbase);
	os << 3.14 << std::ends;

	p = os.str();

	cout << p << endl;

	delete p;

	return 0;
}

/*
run:

C++ Programming
3.14

*/

 



answered Jun 17, 2018 by avibootz
...