Thread: exit

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    8

    exit

    hey,

    u know when ur program runs, u get "press any key to continue" to close the black screen.

    i want it to close by itself.

    can somebody plz tell me wat do i need to write in my program to make this happen?

    thanking u in advance

  2. #2
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    Well, if you are in main or winmain, you can use return 0; to exit the program at any point.


    edit: oops, question misunderstood. So you mean to say your compiler automatically generates code that asks you to press a key?
    Last edited by darksaidin; 08-25-2003 at 01:45 PM.
    [code]

    your code here....

    [/code]

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    8
    i mean that it doesn't display anything. It just exit.

    e.g say it displays "hello world" n then instead of displaying "press any key to continue", it just disappears.

  4. #4
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    Originally posted by nishzone
    i mean that it doesn't display anything. It just exit.

    e.g say it displays "hello world" n then instead of displaying "press any key to continue", it just disappears.
    Oh... well you could find the answer to that in the FAQ...

    anyway, use

    system("PAUSE");

    and don't tell anyone I told you =)
    [code]

    your code here....

    [/code]

  5. #5
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,090
    It sounds like you are asking to do the opposite of what so many people want when they ask this type of question. You don't want to have the 'Press any key to continue' displayed after your program runs. Is that right?

    If so, I am assuming you are using Visual C++. When you hit 'Execute', it automatically adds that so that the console window won't disappear with all your output. If you double-click on the .exe file yourself then it should disappear after the program finishes. I don't know how to make Visual C++ not leave the console window up after execution. I usually use 'Go' (F5) in the debugger anyway which doesn't wait for a key press.

    I apologize if my assumptions are wrong. Hope that helps.

  6. #6
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    I don't know if this helps but I think exit() is defined in iostream:
    Code:
    exit(EXIT_FAILURE);
    //or
    exit(EXIT_SUCCESS);
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  7. #7
    Registered User
    Join Date
    Mar 2002
    Posts
    249
    Don't post the same thing in two forums.
    Well, there are a few things wrong with your code:

    1) It does not work.
    2) It does not work.
    3) It does not work.

    Hope this helps.

  8. #8
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    Don't post the same thing in two forums.

    Why not?

  9. #9
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by 7stud
    Don't post the same thing in two forums.

    Why not?
    It just goes to show that you, with over 500 posts, have never bothered to READ THE RULES! Even though it's at the top of EVERY SINGLE FORUM...

    Quzah.
    Hope is the first step on the road to disappointment.

  10. #10
    Registered User
    Join Date
    Aug 2003
    Posts
    8
    i've read the rules but i didn't find anything that said that you can't post the same question in two different forums.

    i reason why i do it is because if people in this forum can't help me, i might have better luck in another forum. You seemed to forget the fact that many people are registered to only one forum.

    The people that are registered in more than one forum would recognize the question anyway. They don't have to open it.
    Last edited by nishzone; 08-26-2003 at 10:35 AM.

  11. #11
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    Originally posted by nishzone
    i read the rules but i didn't find anything that said that u can't post the same qustion in 2 different forums.

    i reason y i do it is bcuz if people in this forum can't help, i might might better luck in another forum. Some people r registered to only one forums.

    The people that r registered in more than one forums would recognize the question anyways. They dun have to open it.
    You make it hard to help you. Actually I have not the slightest clue what you just said. It's not that easy to understand american kiddy language if you're not a native speaker.
    [code]

    your code here....

    [/code]

  12. #12
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,090
    I have to agree with 7stud and nishzone on this one. What's wrong with posting the same question to forums on two different sites? The rules say not to post to more than one board, but I always assumed that meant on this site.

    Personally, I just thinks its funny when I find the same question on a different site. Kinda like, 'caught ya!'

    By the way, nishzone, did you get your answer?

  13. #13
    Registered User
    Join Date
    Aug 2003
    Posts
    8
    Originally posted by darksaidin
    You make it hard to help you. Actually I have not the slightest clue what you just said. It's not that easy to understand american kiddy language if you're not a native speaker.
    i'm not american and english is not my first language either. i usually make a lot of typing mistakes too. But i'm trying my best so that it's as understandable as possible.

  14. #14
    Registered User
    Join Date
    Aug 2003
    Posts
    8
    Originally posted by jlou
    By the way, nishzone, did you get your answer?
    nope, i found out that i misunderstood the question that i was asked. So i'm not gonna bother with it anymore.

    i tried so many stuff but i wasn't successful.

    i'm starting to wonder whether it can actually b done.

    A big "Thank you" to everybody who was trying to help though

  15. #15
    Registered User
    Join Date
    Jul 2003
    Posts
    16
    umm... i think i know the problem..
    if you don't use the excute button in VC++ and run the program by itself that pause won't be there.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Chat Program Help?
    By Paul22000 in forum Networking/Device Communication
    Replies: 9
    Last Post: 02-10-2009, 12:35 AM
  2. Odd memory leaks
    By VirtualAce in forum C++ Programming
    Replies: 11
    Last Post: 05-25-2006, 12:56 AM
  3. Replies: 1
    Last Post: 03-21-2006, 07:52 AM
  4. Dynamic array of pointers
    By csisz3r in forum C Programming
    Replies: 8
    Last Post: 09-25-2005, 02:06 PM
  5. exit() ?
    By smd in forum C++ Programming
    Replies: 4
    Last Post: 06-26-2002, 04:31 PM