每个节目都有“注销”字样

时间:2013-12-17 19:17:26

标签: c++ compiler-construction logout

当我编写每个C ++程序时,例如:

#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n;
    cout << "Tell me where to start: ";
    cin >> n;
    while (n>0) {
        cout << n << "\n";
        n = n-1;
    }
    cout << "FIRE!";
    return 0;
}

我用G ++编译它,当我运行它时,它运行良好,但是当它完成时它会在程序的最后一个单词之后显示“logout”字样,如下所示:

Tell me where to start: 10
10
9
8
7
6
5
4
3
2
1
FIRE!logout

[Process completed]

为什么呢?我该如何删除它?

1 个答案:

答案 0 :(得分:7)

这不是来自你的程序。这是因为打开终端的唯一目的是运行程序,当它退出时,终端关闭。

如果你打开一个shell并手动运行你的可执行文件,而不是这个消息,你只需要另一个命令提示符。