简体   繁体   English

每个程序上的“登出”字样

[英]“logout” word on every program

When I write every C++ program, such as that one: 当我编写每个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;
}

I compile it with G++ and, when I run it, it works well, but when it finishes it displays the "logout" word after the program's last word, like this: 我用G ++编译它,当我运行它时,它运行良好,但是当它完成时,它在程序的最后一个单词之后显示“注销”单词,如下所示:

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

[Process completed]

Why? 为什么? And how can I remove it? 我该如何删除它?

It's not from your program. 它不是来自您的程序。 It's because the terminal is opened with the sole purpose of running your program, and as such when it exits, the terminal shuts down. 这是因为打开终端是出于运行程序的唯一目的,因此退出终端时,终端会关闭。

If you open a shell and manually run your executable, instead of this message, you'll simply get another command prompt. 如果您打开外壳程序并手动运行可执行文件,而不是显示此消息,您将仅得到另一个命令提示符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM