Thread: Stupid newbie question

  1. #1
    Registered User CompiledMonkey's Avatar
    Join Date
    Feb 2002
    Location
    Richmond, VA
    Posts
    438

    Stupid newbie question

    I'm playing around a little bit in c++ and I'm using the console. However, I need the console to stay open after my program finishes its run. What do I need to add to do this?

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681

  3. #3
    Registered User CompiledMonkey's Avatar
    Join Date
    Feb 2002
    Location
    Richmond, VA
    Posts
    438
    Thx!

  4. #4
    Registered User big146's Avatar
    Join Date
    Apr 2003
    Posts
    74
    Quote Originally Posted by Thantos
    LOL...Tthantos and his FAQ.

  5. #5
    Registered User electRONix's Avatar
    Join Date
    Jun 2004
    Posts
    13

    Smile Another solution that does the same

    I checked the FAQ, here's another solution works well for windows console applications with C++... I'm not quite sure about its specifics but I'm pretty sure you need to include stdlib...

    Code:
    #include <stdlib.h>
    and have this before you return in main..

    Code:
      system("PAUSE");
    my spider-sense be tingling.

    Ron - SCU Math/CS Major

  6. #6
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    actually it would be better as:
    Code:
    #include <cstdlib>
    But of course thats covered in the faq in which I quote:
    Quote Originally Posted by FAQ Entry
    A poor-mans method of using system(), OS specific.
    Code:
    #include <stdlib.h> 
    
    int main(void)
    {
      system ("pause");
      return(0);
    }
    And I give FAQ links for several reasons:

    1) To remind people they are there
    2) Because often they explain better than I can
    3) Its faster and there is less chance of someone beating me

  7. #7
    Registered User
    Join Date
    Jun 2003
    Posts
    91
    Try

    Code:
    cin.get()  or.....
    
    #include <conio.h>  and
    
    getch()

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stupid, stupid question
    By xelitex in forum C++ Programming
    Replies: 5
    Last Post: 12-22-2004, 08:22 PM
  2. A very stupid newbie question
    By bradleym in forum C Programming
    Replies: 6
    Last Post: 09-14-2002, 04:08 AM
  3. Stupid Question
    By Labelizm in forum Windows Programming
    Replies: 2
    Last Post: 07-24-2002, 04:59 AM
  4. very newbie question: how to copy files
    By webwesen in forum C Programming
    Replies: 26
    Last Post: 04-25-2002, 03:01 PM
  5. Episode II Return Of the newbie : Website IO Question
    By MagiZedd in forum Windows Programming
    Replies: 1
    Last Post: 10-18-2001, 08:58 PM