The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
pause needed for corn shell dennysavard UNIX for Dummies Questions & Answers 7 12-09-2007 10:16 AM
Waht does thou mean, old C code heck High Level Programming 5 01-12-2007 02:31 AM
how to pause another process? daneensign UNIX for Dummies Questions & Answers 1 02-13-2006 08:27 PM
system("PAUSE") Problem..... mbolthouse High Level Programming 2 10-03-2001 10:21 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-14-2006
01000101's Avatar
Registered User
 

Join Date: May 2006
Posts: 15
pause? where art thou?

ok, im somewhat of an advanced programmer for the windows-side of C/C++, and the system command to pause the console is 'system("pause");'.... i just recently transfered over to Slackware 3.3 (yes, its old, but i <3 text), and pause is not the command for pausing the command line. is there any way to do this is *nix where the console pauses until the user hits anykey .... plz dont send my messages saying use cin>> or cin.getline() because thats not what im looking for... i want something similar to windows .com PAUSE.

Thnx
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-14-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,419
Code:
system ("read somevar < /dev/tty");
Although fgetc() seems like a choice....
Reply With Quote
  #3 (permalink)  
Old 05-15-2006
Registered User
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 923
Quote:
Originally Posted by jim mcnamara
Although fgetc() seems like a choice....
Not unless you specifically set stdin to unbuffered...

How about:
Code:
void pause()
{
  system("read -n 1 -p \"Press Any Key To Continue\" < /dev/tty");
  printf("\b \n");
  fflush(stdout);
}
Granted, launching a whole new process isn't the most efficient way to do this, but you never cared about that before, so if you're looking for a quick and simple solution this will work. It will wait for one and only one keyboard hit, unlike jim's similar solution, which waits for the enter key.
Reply With Quote
  #4 (permalink)  
Old 05-15-2006
01000101's Avatar
Registered User
 

Join Date: May 2006
Posts: 15
ahh thank you much. im just going to keep it in that form and just call from the function when needed and use it as a global function. oh btw Corona is the best beer ever invented.

Pe@cE
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:25 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0