Well I have almost finished my first really not too easy program and I'm stuck with one thing:
else if(yesorno=n)
{
}
I'd like to put between the brackets a command that closes the window, can anyone help me?
Thanks in advance.
Well I have almost finished my first really not too easy program and I'm stuck with one thing:
else if(yesorno=n)
{
}
I'd like to put between the brackets a command that closes the window, can anyone help me?
Thanks in advance.
if you want it to exit the program :
return 0;
there's also
exit(1);
COOL PROGRAMS @ www.akilla.tk
Thanks a lot, but I got a problem, please read the following code if you have the time and if you want, but I'd really like to know the problem: it says the "n" is undeclared and you first need to declare that function...I don't know how, please help me (I'm trying to make a countdown):
#include <iostream.h>
int main()
{
int yesorno;
cout<<"Begin countdown? Type y for yes or n for no";
cin>>yesorno;
if(yesorno=y)
{
int x=10;
while(x>0)
{
cout<<x<<endl;
x--;
}
}
else if(yesorno=n)
{
exit(1);
}
else
{
cout<<"Command not understood";
}
return 0;
}
Thanks in advance.
> if(yesorno=y)
should be
if(yesorno == 'y')
same thing for the n
if(yesorno == 'n')
Also, it'd make more sense to declare yesorno a char.
-Govtcheez
[email protected]
thanks, I guess that's the case because it is not a number, but how can I declare yesorno a character? And do I have to put it in the same code block or before?
Also I didn't quite understand that pause thing, how do I stop the dos window from closing when it gets to return 0? Thanks.
I know I am asking boring questions, but this is my really first program I tought to make without just copy/pasting the code so...
Thanks in advance.
what do you want it to do before exiting ?
if you just want to see the box before
closing
use
getchar();
before return 0 or exit (1)
I just need to know now if there's a way to slow down the speed of the countdown because it looks as if it just shows 109876543210BOOM at the same time, can anyone help me?
Thanks.
Lookup the delay() function, maybe that would help.
Thanks all of you!!!
I have finished my first program with success!
I'll definitely join this board
Here I am, and thanks again.
"Nobility is not a birtright, but is defined by someone's actions." Robin Hood