Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,104 questions

40,777 answers

573 users

How to use string stream (stringstream) in C++

Learn & Practice SQL


174 views
asked Jun 18, 2018 by avibootz
edited Jun 18, 2018 by avibootz

2 Answers

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

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

int main()
{
	std::stringstream sst("c and c++ programming");

	std::string s = sst.str();
	cout << s << endl;

	sst << 3.14;

	sst >> s;
	cout << s << endl;

	return 0;
}

/*
run:

c and c++ programming
3.14d

*/

 





answered Jun 18, 2018 by avibootz
0 votes
#include <iostream>
#include <sstream>

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

int main()
{
	std::stringstream sst("c:and:c++:programming");

	std::string s = sst.str();
	cout << s << endl;

	sst << 3.14;

	sst >> s;
	cout << s << endl;

	return 0;
}

/*
run:

c:and:c++:programming
3.14d:c++:programming

*/

 





answered Jun 18, 2018 by avibootz

Related questions

3 answers 449 views
1 answer 163 views
1 answer 113 views
1 answer 27 views
27 views asked Jan 13, 2023 by avibootz
1 answer 88 views
...