Jump to content
  • Advertisement
Sign in to follow this  
liquidAir

A trivial problem in C

This topic is 5004 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know, I could have searched for this on Google, but I really need a quick solution instead of scanning through results (I'm that lazy). I am trying to write a console program which waits for the user to press a key after it's done executing, before it closes. Now, I know I can include conio.h and use the getch() function, but this does not work with Linux. How else can I possibly implement the "Press any key to continue..." feature? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
There is no pause command in Linux.

How about. . .

#include <iostream>

void pause()
{
using namespace std;
cout << "Press enter to continue.";
cout.flush();
cin.sync();
cin.get();
cin.sync();
}

Share this post


Link to post
Share on other sites
Sadly, I'm restricted to C. I cannot use any C++ code.
conio.h is not in the ANSI standard library so I suppose that's why it's not available.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!