문제

When I write every C++ program, such as that one:

#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:

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 ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top