Thread: How to System"pause in C++

  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    8

    How to System"pause in C++

    I'm very new to C++

    in C you put system("pause") at the end before return 0.

    How do you do that in C++?


    I have my answer Thanks
    Last edited by Vorkosigan; 01-22-2004 at 02:41 PM.

  2. #2
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    same thing
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  3. #3
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,090
    Code:
    #include <cstdlib>
    
    int main()
    {
        system("pause");
        return 0;
    }

  4. #4
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    Vorkosigan,

    FYI - 99% of what you do in C, will work in C++. But, sometimes (probably most-times) there is a "better" C+ way.

  5. #5
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    Originally posted by DougDbug
    Vorkosigan,

    FYI - 99% of what you do in C, will work in C++. But, sometimes (probably most-times) there is a "better" C+ way.
    And in this case, in C and C++ there is a better way. Search the board for system("pause")
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    or read the faq
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  7. #7
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    So is that why its bad to use system calls. Its platform specific?
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Platform specific, plus "pause" might point to something else, that could be malicious.

  9. #9
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    plus you made an expensive call to the operating system. Slower, more resources used, chance to fail. Any more questions?
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Popular pages Recent additions subscribe to a feed