Hello,
I want to issue a command line command from c program?
As an example, I want to run a program like mplayer.
How can i do this?
Regards.
Hello,
I want to issue a command line command from c program?
As an example, I want to run a program like mplayer.
How can i do this?
Regards.
Use the system() command in stdlib.h, for example:
Code:system("ls");
Thank you.
Is there a way to check if the statement execution is completed?
It appears like system() waits for the called process to finnish. This is from the man page.
Other than that, I don't know. There might exist a more sophisticated method.Originally Posted by man page
It's up to the implementation (and the command interpreter or shell) but system() often waits for the command to finish and returns the exit code from the program invoked.
On Windows, never use system() (crappy and prohibited by MS)
Use Shell apis
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
The return value of system() is the return code of the program which was executed. As long as the shell, and program, aren't brain-dead, this should be accurate. If system() returns 0, then the command executed successfully.
Alex31, recommending a non-portable call when a portable one is perfectly sufficient is naive.
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}