Compiled Program premature closing
3 posters
Page 1 of 1
Compiled Program premature closing
The riddle program i made closes prematurely.
- Code:
#include<iostream>
#include<string>
#include<windows.h>
using namespace std;
int main ()
{ string a,b,c;
cout<<"bet you can't solve this riddle:";
cout<<'\n';
do
{
cout<<"type in two different numbers in which one is not greater than the other And the other is not greater than the first one"<<'\n'
<< "and you can't cheat by putting in the same number twice";
cout<<'\n';
cout<<"first number:";
cin>> a;
cout<<"second number:";
cin>>b;
if ((a>=b)&&(b>=a))
{cout<<"hey you cheater i said you can't use the same number twice";
Sleep(3000);
break;
}
cout<<"Haha you're wrong" <<'\n'<<"Do you give up:";
cin>>c;
}
while ((c!="yes")&&(a!=b));
cout<<'\n'<<"Awww Well You won. Albeit through negative means";
Sleep(2000);
cout<<'\n'<<[b]"but did you really?"[/b];
Sleep(1000);
cout<<'\n' <<" you only won because you are a cheater and a quitter" <<'\n'<<"so in the end who really won?";
return 0;
}
zodiacescuchion- Skid
- Posts : 28
Re: Compiled Program premature closing
you need a pause statement at the end before return 0 so that it pauses and lets you press enter, and THEN ends the program.
i.e. you can either use
cin.ignore(1);
OR
System("pause"); (i recommend the cin statement instead)
i.e. you can either use
cin.ignore(1);
OR
System("pause"); (i recommend the cin statement instead)
Admin- Pirate King
- Posts : 559
Re: Compiled Program premature closing
Yea I had that problem when I started out too.
Unchained- Mod
- Posts : 448
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum