mac 的x code怎样实现system(“pause”)还有system(“cls”)
分别替换为
getchar()
system(“clear”)
在 macOS 系统下
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
cout << "Hello, world!" << endl;
system("read"); // 模拟 system("pause")
system("clear"); // 模拟 system("cls")
cout << "Bye, world!" << endl;
return 0;
}
system函数用于模拟终端命令(参数为命令),Windows下的命令mac当然无法使用,用system("read") ,system("clear")可以代替。
这里有相同的问题:https://www.jianshu.com/p/376cd80e7d83