1003错误
[Error] cannot pass objects of non-trivially-copyable type ‘std::string {aka class std::basic_string}’ through ‘…’
printf函数输出字符串是针对char *的,即printf只能输出c语言的内置数据类型,而string不是c语言的内置数据类型,所以无法直接printf输出string类型数据。
解决:string str=“人生”; cout << str / printf("%s",str.c_str());(string的成员函数c_str(),该函数返回字符串的首字符的地址。)
同样的问题有:
使用scanf【c语言】输入string【c++】的对象