printf with std :: string?
我的理解是它string是std命名空间的成员,为什么会出现以下情况呢?
#include <iostream>int main(){
using namespace std;
string myString = "Press ENTER to quit program!";
cout << "Come up and C++ me some time." << endl;
printf("Follow this command: %s", myString);
cin.get();
return 0;}每次程序运行时,都会myString打印一个看似随机的3个字符的字符串,例如上面的输出。
相关分类