Help with loop statement

Hi, I started programming c++ about a week ago and I have reached a stump in the road. Whenever I run the program in the decompiler it closed automatically. I tryed using system("pause"),cin.get(), and getch(),getche(); I use Notpad ++ and MinGW to work with and I learn off of cplusplus.com

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <conio.h>

using namespace std;

int main()
{
short int StartingInt;
cout << "Start the number you want it to load at!" << endl;
cin >> StartingInt;

while (StartingInt > 0){
	cout << StartingInt <<", ";
	--StartingInt;

}
cout << "It is done loading." << endl;
cout << "Test!";
getche();
return 0;
}

closed account (28poGNh0)
You mean that you dont have a compiler?
I mean everytime I compile it into a exe it closes when I use it
closed account (28poGNh0)
How about this one

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# include <iostream>
# include <limits.h>
using namespace std;

int main()
{
    short int StartingInt;
    cout << "Start the number you want it to load at!" << endl;
    cin >> StartingInt;

    while (StartingInt > 0){
        cout << StartingInt <<", ";
        --StartingInt;

    }
    cout << "It is done loading." << endl;
    cout << "Test!";
    
    cin.ignore();
    cin.ignore(INT_MAX,'\n');

    return 0;
}
Thanks, it worked!
Topic archived. No new replies allowed.