Thread: how too keep the console page open?

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    183

    how too keep the console page open?

    Hi

    How can I ask the compiler not to close the console till the user pushes the enter button or ...?

    there should be sth better than:
    Code:
    //the main body of the code
    .
    .
    .
    
    
    char temp;
    cin>>temp; 
    
    return 0;

    Thanks

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    See the FAQ section, and do a search of forum, this is a very common question
    Last edited by rogster001; 10-06-2010 at 03:34 AM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    183
    Thanks

    It has been a long time since my last C++ code and I had completely forgot about
    Code:
    cin.get();

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Dec 2009
    Posts
    120
    On windows, you can just put
    Code:
    system("pause");
    above the
    Code:
    return0; }
    line. Many people don't recommend this because it's not portable to another operating system. It works perfectly for just building practice programs in Windows though.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Already mentioned. Suggest you read replies and links before you reply.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Dec 2009
    Posts
    120
    Quote Originally Posted by Elysia View Post
    Already mentioned. Suggest you read replies and links before you reply.
    Maybe the system("pause") was mentioned. But it did not mention where to put it, and it also did not mention that it's fine to use when just practicing on a your PC at home or school. It also did not mention what portable meant, and when portability matters. So I stated those facts, to try and help him out. Suggest you mind your own business and don't tell me what to do when I'm trying to help a beginning programmer.

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by nick753 View Post
    Maybe the system("pause") was mentioned. But it did not mention where to put it,
    Honestly, you cannot figure out where to put it?
    I think the OP has already figured out that part.

    ...and it also did not mention that it's fine to use when just practicing on a your PC at home or school.
    The article lists several alternatives which are better than yours, works almost as well and are portable.

    It also did not mention what portable meant, and when portability matters.
    So you could have googled, or just mentioned that.

    So I stated those facts, to try and help him out. Suggest you mind your own business and don't tell me what to do when I'm trying to help a beginning programmer.
    Then I suggest that you should pay more attention to what replies mention before you reply, as well. And perhaps you should at least try to promote portability. That's what this forum is all about, after all.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Registered User
    Join Date
    Dec 2009
    Posts
    120
    Quote Originally Posted by Elysia View Post
    Honestly, you cannot figure out where to put it?
    I think the OP has already figured out that part.


    The article lists several alternatives which are better than yours, works almost as well and are portable.


    So you could have googled, or just mentioned that.


    Then I suggest that you should pay more attention to what replies mention before you reply, as well. And perhaps you should at least try to promote portability. That's what this forum is all about, after all.
    I'm not even going to argue about this anymore. You act like such a little immature brat in all of your posts, it's easier just to ignore you. I mean seriously, who else would I get into an argument besides you for trying to explain to someone what a few terms mean?

    And another thing, I think this forum is more about trying to help people with what they ask rather trying to promote portability. Portability can kiss my ass. Now excuse me while I go write a VB program that I could never do in C++.

  10. #10
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    266
    Nick, you're the one that got aggressive from the beginning over nothing. Telling someone to mind their own business on a public forum wont fix anything. The OP likely already had a solution from previous post. You should chill out. You go ahead and write some program in VB I'm sure nobody here cares.
    Last edited by Syscal; 10-07-2010 at 08:06 AM.

  11. #11
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by nick753 View Post
    And another thing, I think this forum is more about trying to help people with what they ask rather trying to promote portability. Portability can kiss my ass. Now excuse me while I go write a VB program that I could never do in C++.
    No, it's not. It's about helping users while also teaching them to write standard C++ with portable code. So yes, we do promote portability.
    You can go write whatever you want in VB. No one here is going to care. After all, just because you can't do it doesn't mean we can't do it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory Leak in AppWizard-Generated Code
    By jrohde in forum Windows Programming
    Replies: 4
    Last Post: 05-19-2010, 04:24 PM
  2. Problems with a simple console game
    By DZeek in forum C++ Programming
    Replies: 9
    Last Post: 03-06-2005, 02:02 PM
  3. Big help in Astar search code...
    By alvifarooq in forum C++ Programming
    Replies: 6
    Last Post: 09-24-2004, 11:38 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Web Page Organization
    By Khelder in forum C# Programming
    Replies: 4
    Last Post: 05-06-2004, 10:24 AM