macOS 下使用vs code编写C++,使用system函数是出现“TERM environment variable not set.”,无法使用system函数,请问是什么原因?

我使用的是M1芯片的MacBook,clang++编译器

示例:

#include<iostream>
using namespace std;
int main()
{
    cout << "11111" << endl;
    cout << "11111" << endl;
    cout << "11111" << endl;
    cout << "11111" << endl;
    cout << "11111" << endl;
    system("clear");
    cout << "11111" << endl;
    return 0;
}

结果:

11111
11111
11111
11111
11111
TERM environment variable not set.
11111

img


如果有其他方法也可以实现system的作用,望请告知。

Edit Configurations 里面的:
Environment variables 里面添加一个键值对:
TERM xterm-256color
即可。