Press Any Key

Discussion in 'C++' started by Sprechen sie von C++, Mar 8, 2010.

  1. In a simple program I wrote I am currently using

    system('pause');

    to achieve the desired pause so the the output of a console program will
    work fine in Windows. The problem is that is not the most portable way of
    doing anything.

    What other options do I have available that will replace this in a revision
    of the code.

    --
    http://contract-developer.dyndns.biz
     
    Sprechen sie von C++, Mar 8, 2010
    #1
    1. Advertising

  2. I have noticed this, so given the Linux box, the Windows box, the old Cray
    etc. I guess a new function is needed with some code the identify the
    various #defines.

    A real nuisance is that VS 2008 #defines things that its not 100% compatible
    with.

    Is pause relatively universal?

    --
    http://contract-developer.dyndns.biz

    "Leigh Johnston" <> wrote in message
    news:...
    >
    > "Sprechen sie von C++" <> wrote in message
    > news:ir9ln.16911$...
    >> In a simple program I wrote I am currently using
    >>
    >> system('pause');
    >>
    >> to achieve the desired pause so the the output of a console program will
    >> work fine in Windows. The problem is that is not the most portable way of
    >> doing anything.
    >>
    >> What other options do I have available that will replace this in a
    >> revision of the code.
    >>
    >> --
    >> http://contract-developer.dyndns.biz

    >
    > Console I/O is not addressed by standard C++. You could try an ncurses
    > library if you want something cross platform otherwise you are stuck with
    > writing platform specific code which you can at the very least wrap with
    > an abstraction layer.
    >
    > /Leigh
     
    Sprechen sie von C++, Mar 8, 2010
    #2
    1. Advertising

  3. Sprechen sie von C++

    James Kanze Guest

    On 8 Mar, 16:18, "Sprechen sie von C++" <> wrote:
    > In a simple program I wrote I am currently using


    > system('pause');


    > to achieve the desired pause so the the output of a console
    > program will work fine in Windows. The problem is that is not
    > the most portable way of doing anything.


    I've never needed it in Windows, either. And I've written far
    more console programs than others in Windows.

    > What other options do I have available that will replace this
    > in a revision of the code.


    What do you want to achieve? If you just want to wait for user
    input, std::cin.get() works fine.

    --
    James Kanze
     
    James Kanze, Mar 8, 2010
    #3
  4. Thanks, that might just be more what I need. The other way works no problem
    but I was forgetful of the STL ideas.

    --
    http://contract-developer.dyndns.biz

    "James Kanze" <> wrote in message
    news:...
    > On 8 Mar, 16:18, "Sprechen sie von C++" <> wrote:
    >> In a simple program I wrote I am currently using

    >
    >> system('pause');

    >
    >> to achieve the desired pause so the the output of a console
    >> program will work fine in Windows. The problem is that is not
    >> the most portable way of doing anything.

    >
    > I've never needed it in Windows, either. And I've written far
    > more console programs than others in Windows.
    >
    >> What other options do I have available that will replace this
    >> in a revision of the code.

    >
    > What do you want to achieve? If you just want to wait for user
    > input, std::cin.get() works fine.
    >
    > --
    > James Kanze
     
    Sprechen sie von C++, Mar 8, 2010
    #4
  5. Sprechen sie von C++ wrote:
    > In a simple program I wrote I am currently using
    >
    > system('pause');
    >
    > to achieve the desired pause so the the output of a console program will
    > work fine in Windows. The problem is that is not the most portable way
    > of doing anything.
    >
    > What other options do I have available that will replace this in a
    > revision of the code.
    >


    http://linux.die.net/man/3/sleep

    Not sure if it works on windows
     
    Vladimir Jovic, Mar 9, 2010
    #5
  6. I am using the cin.get() approach as that seems to work best for me.

    --
    http://contract-developer.dyndns.biz

    "Vladimir Jovic" <> wrote in message
    news:hn4vre$q5k$...
    > Sprechen sie von C++ wrote:
    >> In a simple program I wrote I am currently using
    >>
    >> system('pause');
    >>
    >> to achieve the desired pause so the the output of a console program will
    >> work fine in Windows. The problem is that is not the most portable way of
    >> doing anything.
    >>
    >> What other options do I have available that will replace this in a
    >> revision of the code.
    >>

    >
    > http://linux.die.net/man/3/sleep
    >
    > Not sure if it works on windows
     
    Sprechen sie von C++, Mar 10, 2010
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Howard

    Press any key

    John Howard, Jul 12, 2003, in forum: C++
    Replies:
    3
    Views:
    538
  2. JKop

    Press any key to...

    JKop, Sep 16, 2004, in forum: C++
    Replies:
    2
    Views:
    2,612
    osmium
    Sep 16, 2004
  3. Andrew Robert
    Replies:
    51
    Views:
    22,611
    Mark McIntyre
    Nov 13, 2003
  4. Timur Ametov

    Message "Press any key to continue"

    Timur Ametov, Apr 26, 2006, in forum: C++
    Replies:
    8
    Views:
    465
    Default User
    Apr 27, 2006
  5. Replies:
    0
    Views:
    463
Loading...

Share This Page