用"printf"输出string类字符

在遇到大量输入输出的时候,我们知道printf & scanf的效率要大于cin & cout。

但在用到STL的时候,又难免用到string,于是有以下方法。

View Code
1 string test("nothing");
2 printf("%s", test.c_str());

  

posted @ 2011-08-12 17:46  alex4814  阅读(740)  评论(0编辑  收藏  举报