Currently I have a map that prints out the following
map<string, map<int,int> > mapper;
map<int,int>::iterator inner;
map<string, map<int,int> >::iterator outer;
for(outer = mapper.begin(); outer != mapper.end(); outer++){
cout<<outer->first<<": ";
for(inner = outer->second.begin(); inner != outer->second.end(); inner++){
cout<<inner->first<<","<<inner->second<<",";
}
}
As of now this prints out the following
stringone: 1,2,3,4,6,7,8,
stringtwo: 3,5,6,7,
stringthree: 2,3,4,5,
What i want it to print out is
stringone: 1,2,3,4,6,7,8
stringtwo: 3,5,6,7
stringthree: 2,3,4,5
how can i check for the end of the map inside my inner map?
Any help would be appreciated Thank you
Change your output line to print the comma first and only if it is not the first element: