首页 > 解决方案 > 为什么字符串声明会终止 VScode 中的程序?

问题描述

我在带有 mingw 的 Windows 中使用 VScode。我已经安装了 C/C++ 扩展并正确配置了Intellisense 模式tasks.json(我遵循了本教程https://code.visualstudio.com/docs/cpp/config-mingw#_build-helloworldcpp)。在我使用字符串之前一切正常。我可以毫无问题地使用其他数据类型和容器。

#include<bits/stdc++.h>
using namespace std;
int main()
{
    cout<<"working";
    string s;
    cin>>s;
    cout<<s;
    return 0;
}

该程序终止而不打印任何内容,尽管它不会引发任何错误。

标签: c++stringvisual-studio-code

解决方案


推荐阅读