简体   繁体   中英

Visual Studio 2015 - Local Windows Debugger closes out immediately after run?

Hi I'm a highschool student in need of help. I am interested in C++ as I wish to become a programmer one day. I started using Visual Studio for C++ and I'm running a few simple lines of code. But everytime I press (Ctrl + F5) or Local Windows Debugger it shows my line of code but it closes out immediately after it runs, making it near impossible to read. The code is the classic "Hello World!" code. Maybe it has to do something with return 0;?

EDIT: Here's my code.

#include <iostream>
using namespace std;

int main()
{
    int mark = 90;
    if (mark < 50) {
        cout << "HES OLD" << endl; 
    }
    else {
        cout << "Hes not old!" << endl;
    }
}

When making console applications, I use the following lines at the end of my main function:

std::cout << "\nPaused. Press Enter to continue.\n";
std::cin.ignore(100000, '\n');

The idea is to display a prompt and then wait for the Enter key to be pressed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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