pause? where art thou?


 
Thread Tools Search this Thread
Top Forums Programming pause? where art thou?
# 1  
Old 05-14-2006
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
# 2  
Old 05-14-2006
Code:
system ("read somevar < /dev/tty");

Although fgetc() seems like a choice....
# 3  
Old 05-15-2006
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.
# 4  
Old 05-15-2006
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
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pause before exit

6) printf "\n GoodBye! \n\n"; exit ;; I am trying modify the above command to pause a couple of seconds before exiting, so a message can be displayed. Thank you :). (8 Replies)
Discussion started by: cmccabe
8 Replies

2. UNIX for Advanced & Expert Users

O argv, argv, wherefore art thou argv?

All of my machines (various open source derivatives on x86 and amd64) store argv above the stack (at a higher memory address). I am curious to learn if any systems store argv below the stack (at a lower memory address). I am particularly interested in proprietary Unices, such as Solaris, HP-UX,... (9 Replies)
Discussion started by: alister
9 Replies

3. UNIX for Dummies Questions & Answers

pause() problems

well is gets stuck and i dont know why....... pid=fork(); if(pid==0) { pause(); write(1,"child",5); exit(0); } else { sleep(1); kill(pid,SIGCONT); write(1,"parent",5); wait(0); } all=1; (1 Reply)
Discussion started by: IdleProc
1 Replies

4. Programming

Waht does thou mean, old C code

ok... Take a look at the snippets below. What does it mean a construct like: void function() type var; { funct code... } hmmm.. i dont get it. my compiler either. void log_message(filename,message) char *filename; char *message; { FILE *logfile; logfile=fopen(filename,"a");... (5 Replies)
Discussion started by: heck
5 Replies

5. UNIX for Dummies Questions & Answers

how to pause another process?

I guess I posted in wrong forum before. How do I pause another process and then restart it on linux? The other process doesn't listen for anything. Thanks for any help you can offer. Dane :confused: (1 Reply)
Discussion started by: daneensign
1 Replies
Login or Register to Ask a Question