Thread: how to command to close a dos window?

  1. #1
    Unregistered
    Guest

    how to command to close a dos window?

    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.

  2. #2
    Akilla
    Guest

    exit ?

    if you want it to exit the program :

    return 0;

    there's also

    exit(1);

    COOL PROGRAMS @ www.akilla.tk

  3. #3
    Unregistered
    Guest

    yes, exit, but problem

    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.

  4. #4
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    > 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.

  5. #5
    Unregistered
    Guest

    thanks but another question

    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.

  6. #6
    JonnyHatesJesus
    Guest

    hmm

    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)

  7. #7
    Unregistered
    Guest

    thanks the last question and my program will be wonderful

    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.

  8. #8
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    Lookup the delay() function, maybe that would help.

  9. #9
    Unregistered
    Guest

    thanks all!

    Thanks all of you!!!

    I have finished my first program with success!

    I'll definitely join this board

  10. #10
    Registered User
    Join Date
    Jul 2002
    Posts
    15

    I am now a member

    Here I am, and thanks again.
    "Nobility is not a birtright, but is defined by someone's actions." Robin Hood

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  2. how do i close one window at a time?
    By stde in forum Windows Programming
    Replies: 4
    Last Post: 08-01-2006, 12:43 PM
  3. My Window Class
    By Epo in forum Game Programming
    Replies: 2
    Last Post: 07-10-2005, 02:33 PM
  4. input/output
    By dogbert234 in forum Windows Programming
    Replies: 11
    Last Post: 01-26-2005, 06:57 AM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM