Highly Frustrating Problem

This is a discussion on Highly Frustrating Problem within the C++ Programming forums, part of the General Programming Boards category; Im just started doing the tutorials at cprogramming.com and in the 1st lesson, with the "Hello World" program, when execute ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    12

    Highly Frustrating Problem

    Im just started doing the tutorials at cprogramming.com and in the 1st lesson, with the "Hello World" program, when execute it, the console window opens and displays "Hello World!" then quits
    without any user input, how can i stop this?

  2. #2
    Registered User
    Join Date
    Aug 2002
    Posts
    12
    I've noticed too and although I'm too much of a newbie to help. When I ran it from within MSVC++ its ok. I'm sures theres a simple way of holding that window open rather then auto closing it (which I think only win 2k and xp do)

  3. #3
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    just add
    Code:
    system("pause"); // must #include <stdlib.h>
    
    // or
    
    /* declare a variable and make the user enter something before they can quit */
    int hit;
    cin >> hit; // must #include <iostream.h>
    
    // simply
    getch(); // dunno what header
    Please direct all complaints regarding this post to the nearest brick wall Have a nice day.

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    getch() is <conio.h>
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    362
    For those who may have instructors who are finicky about using standard headers, use face_master's suggestion of system("PAUSE"); with #include <cstdlib>. (I've used <conio.h> extensively in the past for getch(); and clrscr();, but...)

    (I noticed a thread a day, or so, ago from a student whose teacher disallowed the use of non-standard headers. )

    -Skipper
    "When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow

  6. #6
    Registered User
    Join Date
    Sep 2002
    Posts
    12
    Ok thanks, ill try that when I get home, if it doesnt work or something ill post again....


    And by the way, how do all you programmers find out what every .h program does?

  7. #7
    Registered User heat511's Avatar
    Join Date
    Dec 2001
    Posts
    169

    memorization! :)

    not really

    just as you come across something you need to use a new library for you learn what features it has and what it can do.
    "uh uh uh, you didn't say the magic word"
    -Jurassic Park

  8. #8
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    I look up a function on MSDN and figure out what header it needs... if I ever need the function again, I include the header...
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 10:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21