Console close midway code

Probably a tiny issue which may be slightly different from the thread 'Console Closing down'...
My console runs okay, the only thing is, it runs up until cin >> b
then the Console closes.
Wondering if anyone can cast an expert eye of this simple code and assist


#include <iostream>
using namespace std;
int main()
{
short int a, b;
cout << "Enter a high value\n";
cin >> a;
cout << "Enter a lower value than" << a << "\n";
cout <<"\n";
cin >> b;

if (b>a)
cout << "Please enter a lower digit\n";
else
cout << "Good you entered" << b << "which is lower than" << a <<;
cout << b << "is changed to" << a <<;
return 0;

}


Many thanks
Nope, this is the same as in 'Console closing down'. Just add cin.ignore().get(); before returning and it should be fine.
By the way, what's with the <<; ? That shouldn't compile ..
Thanks for the quick response hamsterman-very much appreciated. I did as advised, however, still no joy.
See snapshot below, could you review and advise please?
#include <iostream>
using namespace std;
int main()
{
short int a, b;
cout << "Please enter a high value\n";
cin >> a;
cout << "Now enter a lower value than " << a << "\n";
cout <<"\n";
cin >> b;

if (b>a)
cout << "Please try entering a lower value\n";
else
cout << "Good you entered" << b << "which is lower than" << a;
cin.ignore();
return 0;
}

I am able to enter the higher and lower value or vice-versa; but the statements after the if statement only flashes for a second and then the console disappears...
again.
Cheers
For some odd reason, it worked today, well just by hoping-:) perhaps because I used 'Start Without debugging' option? I don't know...hmmm Computers.
Topic archived. No new replies allowed.