C风格字符串等价于string 类型字符串字面值
string str1("Hello!"); //ok.
char *str2 = str1; //error.
char *str3 = str2.c_str(); //ok. but not quite.
//注意c_str()返回的数据类型是const char
const char *str4 = str2.c_str(); //ok.![](http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=982263437555584821&page=RSS%ef%bc%9aC%e9%a3%8e%e6%a0%bc%e5%ad%97%e7%ac%a6%e4%b8%b2%e4%b8%8estring%e7%b1%bb%e5%9e%8b&referrer=)
![](http://c.live.com/c.gif?NC=31263&NA=1149&PI=81873&RF=&DI=3919&PS=85545&TP=liyuxia-life.spaces.live.com>1=liyuxia-life)
文章来源:http://liyuxia-life.spaces.live.com/Blog/cns!DA1B364675ACF35!232.entry