我在学校用NetBeans 8.2用C ++编程,这些计算机具有Ubuntu 14.04和gcc-4.3

提示随机运行,但不会在日志中发送任何错误。

这里的每台计算机都有相同的问题。

main.cpp:

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char** argv) {

    cout << "Hello World!" << endl;
    return 0;
}


可能的(和预期的)输出:

Hello World!

RUN FINISHED; exit value 0,; real time: 0ms; user: 0ms; system: 0ms


其他可能的输出:

RUN FINISHED; exit value 0,; real time: 0ms; user: 0ms; system: 0ms

最佳答案

有时,编译器会打印出来并完成而不会引起注意。因此,您可以使用cin来检查是否正在发生这种情况。

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char** argv) {

    cout << "Hello World!" << endl;
    int test;
    cin >> test;
    return 0;
}


在这里,编译器将等待您输入值,因此您将有足够的时间来查看输出。

08-27 00:06