How to output string stream (stringstream) into variables in C++

1 Answer

0 votes
#include <iostream>
#include <sstream>

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

int main()
{
	std::stringstream sst;

	sst << "Values: " << 100 << " " << 3.14;

	int i;
	double d;
	std::string s;

	sst >> s >> i >> d;
	cout << s << " " << i << " " << d << endl;

	return 0;
}

/*
run:

Values: 100 3.14

*/

 



answered Jun 18, 2018 by avibootz
edited Jun 18, 2018 by avibootz

Related questions

3 answers 652 views
1 answer 336 views
2 answers 341 views
2 answers 239 views
1 answer 193 views
193 views asked Nov 12, 2016 by avibootz
1 answer 96 views
...