I know windows uses the pause system call to wait for a keypress on stdin i.e. system("pause");.
is there an equivelant system call that I can use in linux??
or will I have to use fgetc();?
I know windows uses the pause system call to wait for a keypress on stdin i.e. system("pause");.
is there an equivelant system call that I can use in linux??
or will I have to use fgetc();?
Well reading a char from stdin would be the most portable way of doing it.
Are you absolutely sure you need it. Most windows people just need it to stop the popup DOS box which is created from disappearing again before they can read anything.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I agree with Salem, but if you need it all you have to do isit always returns -1 so you don't really need to get its return value. This has been replaced though, with sigsuspend();Code:#include <unistd.h> /*code*/ pause();A little more confusing but reliableCode:#include <signal.h> /*code*/ sigset_t mask, oldmask; ... /* Set up the mask of signals to temporarily block. */ sigemptyset (&mask); sigaddset (&mask, SIGUSR1); ... /* Wait for a signal to arrive. */ sigprocmask (SIG_BLOCK, &mask, &oldmask); while (!usr_interrupt) sigsuspend (&oldmask); sigprocmask (SIG_UNBLOCK, &mask, NULL);
[sources]
sigsuspend example
man pause
man sigsuspend
[/sources]
I was recieving a response from a server via sockets. wanted to dispay the responce, then pause, then clear the terminal to restart the program.
Though now I think about it, clearing the response that the server sends isnt such a good idea is it. lol
Thanx for your help guys