这是 this question 的一种重复.我遵循了建议(我认为)并包含了 <string>
但是我的脸上出现了完全相同的错误:
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
#include <string>
#include <iostream>
using namespace std;
int main() {
string texte;
texte = "pouet";
wcout << texte << endl;
return 0;
}
编辑:我一点也不自豪地说这个问题是由于我没有选择正确的项目作为“启动项目”造成的。 Visual Studio 有点难以理解……但是,最初的真正问题与我的真实项目有关,是关于无法通过
wcout
输出的标准字符串。 .我重新格式化了问题以相应地重新定位主题。随心所欲地对我投反对票,我应得的......
最佳答案
std::basic_string
的输出运算符未重载对流的任意字符类型进行操作。您的选择是:
std::wstring
来自您的 std::string
,例如:std::wcout << std::wstring(texte.begin(), texte.end());
std::wcout << texte.c_str();
关于c++ - 我无法用 wcout 输出字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32426698/