How to input values into char array using ostrstream in C++

1 Answer

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

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

int main()
{
	char s[32];

	std::ostrstream oss(s, sizeof(s));
	oss << "c / c++ ";
	oss << 3.14 << std::hex << " ";
	oss.setf(std::ios::showbase);
	oss << 155 << std::ends;

	cout << s << endl;

	return 0;
}

/*
run:

c / c++ 3.14 0x9b

*/

 



answered Jun 19, 2018 by avibootz

Related questions

1 answer 139 views
139 views asked May 20, 2018 by avibootz
1 answer 138 views
2 answers 180 views
1 answer 144 views
3 answers 241 views
2 answers 159 views
1 answer 158 views
...