jeudi 20 janvier 2022

Can't run C++ .exe created by VSCode

I use VSCode to create the .exe file of the simple following C++ code:

#include <iostream>
using namespace std;

int main()
{
    int x = 25;
    cout << x << endl;
    return 0;
}

When I open the .exe program created, the window appears and shuts down immediately. If I put getchar() before return 0, I can make the program wait for user input to fix it. However, if I use Dev-C or Codeblocks, this problem does not happen. In other word, I do not need to add getchar() to hold the window. Hope that someone can explain what problem occurs and how can I fix it to make the .exe created by VSCode run normally? Thank you so much.

Aucun commentaire:

Enregistrer un commentaire