保存使“ \ n”在我在vscode上的代码中在C ++中换行

问题描述

所以我有一个未保存的程序,这是它的样子

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    vector<string> msg{"Hello","C++","World","from","VS Code","and the C++ extension!"};

    for (const string& word : msg) {
        cout << word << " ";
    }
    cout << '\n';
    cout << "Hello world" << "\n";
}

一旦保存,就会发生这种情况

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    vector<string> msg{"Hello","and the C++ extension!"};

    for (const string& word : msg) {
        cout << word << " ";
    }
    cout << '\n';
    cout << "Hello world"
         << "\n";
    return 0;
}

到目前为止,我知道我唯一已应用的样式是Google样式指南,该样式在今天早些时候有效,但现在它正在执行。我也收到此错误first.cpp:8:23: error: expected ';' at end of declaration vector<string> msg{"Hello","and the C++ extension!"};

解决方法

尝试仅使用

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...