Link to home
Start Free TrialLog in
Avatar of Pawan Patil
Pawan Patil

asked on

Printing the elements of a set declared inside a map in C++.

Hi all, I am trying to print the elements of the set declared inside a map in c++. However, the code isn't printing the elements. I have this code :
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <map>
#include <utility>
#include <stdio.h>
#include <ctype.h>
#include <typeinfo>
#include <string.h>
#include <vector>
#include <algorithm>
#include <set>



using namespace std;

int main()
{
	std::set<string> st;
	std::map<string,std::set<string> > mp;
	std::map<string,std::set<string> >::iterator row;
	std::set<string>::const_iterator col;

	mp["A"].insert("pawan");
	mp["A"].insert("patil");

	
	for (row = mp.begin(); row!=mp.end(); row++) 
	{
		cout<<row->first;
    	for (col = row->second.begin(); col!=row->second.end(); ++col);
    	{
    		cout<<*col<<" ";
    	}
    	cout<<mp["A"].size()<<"\n";
	}
	//cout<<row->second;
	
	return 0;
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of phoffric
phoffric

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial