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

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,948 questions

51,890 answers

573 users

How to print set with for loop in C++

1 Answer

0 votes
#include <iostream>
#include <set>
#include <string>

using std::cout;
using std::endl;
using std::string;
using std::set;

int main()
{
	set<string> st;

	st.insert("c++");
	st.insert("c");
	st.insert("java");
	st.insert("php");
	st.insert("python");

	typedef set<string>::const_iterator ci;
	for (ci it = st.begin(); it != st.end(); it++)
		cout << *it << " ";
	cout << endl;

	return 0;
}


/*
run:

c c++ java php python

*/

 



answered Apr 23, 2018 by avibootz

Related questions

2 answers 275 views
1 answer 104 views
104 views asked Mar 14, 2024 by avibootz
1 answer 125 views
1 answer 152 views
152 views asked Jun 14, 2020 by avibootz
2 answers 199 views
199 views asked Apr 24, 2018 by avibootz
1 answer 117 views
2 answers 180 views
...