Visual studio 2010 exiting after program ends

前端 未结 8 654
甜味超标
甜味超标 2021-02-04 13:44

I\'m trying out Visual studio 2010 by compiling a C program. After it displays the solution in the \"DOS\" command window, the window is immediately closed. In Visual studio 200

相关标签:
8条回答
  • 2021-02-04 14:40

    You can add this function and call it right before returning from main():

    void keep_window_open()
    {
        // clear buffer
        fflush(stdin);
        printf("Please enter a character to exit\n");
        char ch;
        ch = getchar();
        return;
    }
    

    I adapted it from a C++ version in a utility header file at Bjarne Stroustrup's site: http://www.stroustrup.com/Programming/std_lib_facilities.h

    0 讨论(0)
  • 2021-02-04 14:42

    If you start your application without debugger ("Start without debugging"), the console window will remain open until you press a key.

    0 讨论(0)
提交回复
热议问题