c++ Cygwin system(“pause”); and system(“cls”); error

8iwquhpp  于 11个月前  发布在  其他
关注(0)|答案(1)|浏览(91)

这是我的C++代码:

#include <iostream>
#include <cstdlib>
using namespace std;

int main() {
   cout << "Hello, world!" << endl;
   system("pause");
   system("cls");
   return 0;
}

字符串
我在cygwin编译它,我有这个错误:sh:line 1:pause:command not found sh:line 1:cls:command not found.我已经安装了ncurses,但它仍然不工作,有人能帮助吗?

wlsrxk51

wlsrxk511#

如果你真的想运行这个程序,你可以使用system("cmd.exe /c pause")system("cmd.exe /c cls")。然而,正如其他人已经指出的那样,它可能是不完整的或存在安全风险。

相关问题