Thread: [Dev-C++] DEV-C++ Does Not Pause
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Administrator <ad_...@ho...> - 2002-10-10 14:27:09
|
//start of code
#include <iostream.h> =09
int main() //Most important part of the program!
{
int age; //Need a variable...
cout<<"Please input your age: "; //Asks for age
cin>>age; //The input is put in age
if(age<100) //If the age is less than 100
{
cout<<"You are pretty young!"; //Just to show it works
}
else if(age=3D=3D100) //I use else just to show an example=20
{
cout<<"You are old"; //Just to show you it works...
}
else
{
cout<<"You are really old"; //Executed if no other statement is =
executed
}
return 0;
}
//end of code
when I enter "my age" then I must press <ENTER> to run the if =
statements, The DOS window stays up till i press <ENTER> to process.=20
I cant get the movie to pause and give me the result "You are old". "You =
are really old" or whatever the result must be.
How can I pause the movie and process it?
I tried:
//code
system("PAUSE");
return 0;
}
//code
but this just trows an error.
Also I tried to run the EXE by itself, but again, it does the same thing
Thanks for your help |
|
From: Elizabeth B. <sog...@ya...> - 2002-10-10 14:43:34
|
You could do another cin.
"Administrator" <ad_...@ho...> writes:
> This is a multi-part message in MIME format.
>
> ------=_NextPart_000_004F_01C2703F.657C9830
> Content-Type: text/plain;
> charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
>
> //start of code
>
> #include <iostream.h> =09
>
> int main() //Most important part of the program!
>
> {
>
> int age; //Need a variable...
char dummy; // for pausing...
>
> cout<<"Please input your age: "; //Asks for age
>
> cin>>age; //The input is put in age
>
> if(age<100) //If the age is less than 100
>
> {
>
> cout<<"You are pretty young!"; //Just to show it works
>
> }
>
> else if(age=3D=3D100) //I use else just to show an example=20
>
> {
>
> cout<<"You are old"; //Just to show you it works...
>
> }
>
> else
>
> {
>
> cout<<"You are really old"; //Executed if no other statement is =
> executed
>
>
> }
cout << "Hit enter to continue." << endl;
cin >> dummy;
>
> return 0;
>
> }
>
> //end of code
-e
|
|
From: Rafael C. <cha...@un...> - 2002-10-10 15:00:43
|
Hi,
You probably have a compilation error.
system("PAUSE") needs stdlib.h (#include <stdlib.h>)
Rafael
cha...@un...
Administrator wrote:
> //start of code
>
> #include <iostream.h>
//include stdlib
#include <stdlib.h>
>
> int main() //Most important part of the program!
>
> {
>
> int age; //Need a variable...
>
> cout<<"Please input your age: "; //Asks for age
>
> cin>>age; //The input is put in age
>
> if(age<100) //If the age is less than 100
>
> {
>
> cout<<"You are pretty young!"; //Just to show it works
>
> }
>
> else if(age==100) //I use else just to show an example
>
> {
>
> cout<<"You are old"; //Just to show you it works...
>
> }
>
> else
>
> {
>
> cout<<"You are really old"; //Executed if no other statement is executed
>
>
> }
>
> return 0;
>
> }
> //end of code
>
> when I enter "my age" then I must press <ENTER> to run the if
> statements, The DOS window stays up till i press <ENTER> to process.
>
> I cant get the movie to pause and give me the result "You are old". "You
> are really old" or whatever the result must be.
>
> How can I pause the movie and process it?
>
> I tried:
>
> //code
> system("PAUSE");
> return 0;
> }
> //code
>
> but this just trows an error.
>
> Also I tried to run the EXE by itself, but again, it does the same thing
>
> Thanks for your help
|
|
From: Santiago <sa...@ho...> - 2002-10-11 00:05:44
|
just type cin.ignore(); below the cin>>age; statement Check this link for more info: http://www.gunn.palo-alto.ca.us/~jkleinjans/ignore.html ----- Original Message ----- From: "Rafael Charnovscki" <cha...@un...> To: "Administrator" <ad_...@ho...> Cc: "Dev-Cpp List" <dev...@li...> Sent: Thursday, October 10, 2002 10:58 AM Subject: Re: [Dev-C++] DEV-C++ Does Not Pause > Hi, > You probably have a compilation error. > system("PAUSE") needs stdlib.h (#include <stdlib.h>) > > Rafael > cha...@un... > > Administrator wrote: > > //start of code > > > > #include <iostream.h> > > //include stdlib > #include <stdlib.h> > > > > > int main() //Most important part of the program! > > > > { > > > > int age; //Need a variable... > > > > cout<<"Please input your age: "; //Asks for age > > > > cin>>age; //The input is put in age > > > > if(age<100) //If the age is less than 100 > > > > { > > > > cout<<"You are pretty young!"; //Just to show it works > > > > } > > > > else if(age==100) //I use else just to show an example > > > > { > > > > cout<<"You are old"; //Just to show you it works... > > > > } > > > > else > > > > { > > > > cout<<"You are really old"; //Executed if no other statement is executed > > > > > > } > > > > return 0; > > > > } > > //end of code > > > > when I enter "my age" then I must press <ENTER> to run the if > > statements, The DOS window stays up till i press <ENTER> to process. > > > > I cant get the movie to pause and give me the result "You are old". "You > > are really old" or whatever the result must be. > > > > How can I pause the movie and process it? > > > > I tried: > > > > //code > > system("PAUSE"); > > return 0; > > } > > //code > > > > but this just trows an error. > > > > Also I tried to run the EXE by itself, but again, it does the same thing > > > > Thanks for your help > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |