stringstream

http://sealbird.iteye.com/blog/866701


这位哥们写的代码有点问题,要测试一下再用。


map<string, int > mapTest;    


for (int i=0; i<10; i++)
{
stringstream ss;  
string str_name;
  str_name = "zhou";
ss<<i;
string tmp;
ss>>tmp;
cout<<tmp<<endl;
str_name = str_name + tmp;
cout<<str_name<<endl;
mapTest.insert(map<string ,int>::value_type(str_name, i));
}

我把int 转成string,stringstream是最方便的方式吧。不过要注意到底是谁传给谁值啊。<<拥抱是源头,在背后的才是接收者啊。


你可能感兴趣的:(stringstream)