【发布时间】:2014-01-14 02:42:55
【问题描述】:
我目前正在关注由 thenewboston 在 youtube 上创建的教程。我没有逐字逐句地遵循它,但已经足够接近了。
我的简单程序:
#include <iostream>
#include <string.h> /* memset */
#include <unistd.h> /* close */
#include <stdio.h>
#include <stdlib.h>
#include <cstdlib>
int main(){
using namespace std;
cout << "Those who wander too far off the path of reality. Will be plunged into total Madness." << endl;
cout << " - BinKill-Ethical" << endl;
system("cls");
return 0;
}
这是我创建的第一个 C++ 程序。我几乎一无所知,但我无法让 system() 函数工作。
输出:
除了#include <iostream> 之外的所有内容都是来自其他 stackoverflow 帖子的建议,以尝试使其正常工作。没有一个工作。如果这很重要,我正在使用 G++ 进行编译。
【问题讨论】:
-
就 C++ 而言,
system不能保证任何结果。你没有cls命令(Windows 默认有,这就是教程使用的)。 -
使用
system("cmd /c cls"); -
@CaptainObvlious,不是 Windows,由
<unistd.h>判断。 -
既然你有输出“cls: not found”,这意味着你的system()函数正在工作!
-
但是“CLS”不是。