How to System"pause in C++

This is a discussion on How to System"pause in C++ within the C++ Programming forums, part of the General Programming Boards category; I'm very new to C++ in C you put system("pause") at the end before return 0. How do you do ...

  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 01: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,088
    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,161
    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?

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,781
    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,161
    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

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