console closes when i enter input

Write your question here.
just started using visual studio...at first the console only opened for a second and i found an answer to that....now it stays open til i enter input. then output appears for less than a second and disappears. thanks for any help
Last edited on
See the sticky: http://www.cplusplus.com/forum/beginner/1988/

And this: https://stackoverflow.com/questions/1775865/preventing-console-window-from-closing-on-visual-studio-c-c-console-applicatio

Or, just run your program by opening cmd and then navigating to where your actual .exe file is.
A thing I use in all my programs:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include </*whatever you need*/>

using namespace std;


void pause(); //this

int main()
{
    //your program

    pause();

    return 0;
}

void pause()
{
    cout << "\n\nPress ENTER to continue...";
    cin.sync();
    cin.get();
    cout << "\n\n";

    return;
}


Hope this helps :)
Last edited on
Topic archived. No new replies allowed.