[ create a new paste ] login | about

Link: http://codepad.org/goQIYQDs    [ raw code | output | fork ]

C++, pasted on Apr 5:
#include <map>
#include <sstream>//äëÿ ôàéëîâîãî i/o çàìåíèòü íà fstream
#include <string>
#include <iostream>
using namespace std;

int main()
{
	map<string, string> pData;
	pData[string("color1")] = "red";
	pData[string("color2")] = "grn";
	pData[string("color3")] = "blu";

	stringstream ss;//äëÿ ôàéëîâîãî i/o áóäåò ofstream + ss.open(...)
	map<string, string>::iterator it;

	cout<<"INPUT : "<<endl;
	for( it = pData.begin(); it != pData.end(); it++ ){
		ss<<(*it).first<<endl<<(*it).second<<endl;
		cout<<(*it).first<<" -> "<<(*it).second<<endl;
	}

	string key;
	string value;
	map<string, string> pCopy;
	while( !ss.eof() )
	{
		ss>>key>>value;
		pCopy.insert(make_pair(key, value));
	}

	cout<<"OUT : "<<endl;
	for( it = pCopy.begin(); it != pCopy.end(); it++ ){
		cout<<(*it).first<<" -> "<<(*it).second<<endl;
	}

	return 0;
}


Output:
1
2
3
4
5
6
7
8
INPUT : 
color1 -> red
color2 -> grn
color3 -> blu
OUT : 
color1 -> red
color2 -> grn
color3 -> blu


Create a new paste based on this one


Comments: