g++/msys64/mingw64/vs代码编译问题
当使用MSYS64使用G ++ 12.1.0在VS代码中使用G ++编译器时,我可以编译一个基本的Hello World程序,但是一旦我介绍了使用矢量的代码,我想象其他标准的C ++ libs,则该程序的编译,但是输出为输出,空白的。如果我去过去的G ++/MSYS64/Mingw64构建(G ++ 10.3.0)标准Libs的构建工作,我使用COUT从向量中获得输出。我想知道其他人是否有这个问题以及如何解决?
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
cout << "Hello World" << endl;
string test = "test String, test vector";
// if I comment out vector related code output works with cout
vector<string> testVec(2);
testVec.at(0) = test;
testVec.at(1) = test;
cout << testVec.at(0) << testVec.at(1) << endl;
vector<string> msg{"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};
for (const string &word : msg)
{
cout << word << " ";
}
return 0;
}
When using the g++ compiler in VS Code using the MSYS64 using g++ 12.1.0 I can compile a basic hello world program, but as soon as I introduce code with a vector and I imagine other standard C++ libs, the program compiles however, output is blank. If I go to a past build of g++/MSYS64/Mingw64 builds (g++ 10.3.0) standard libs work, I get output from vectors using cout. I wonder if anyone else has this problem and how to fix it?
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
cout << "Hello World" << endl;
string test = "test String, test vector";
// if I comment out vector related code output works with cout
vector<string> testVec(2);
testVec.at(0) = test;
testVec.at(1) = test;
cout << testVec.at(0) << testVec.at(1) << endl;
vector<string> msg{"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};
for (const string &word : msg)
{
cout << word << " ";
}
return 0;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论