When I use the function "system()", it returns number 0, as it is supposed to.
How can I make it to return a string? For example, I want it to return the PID of some process, using the Linux shell command "pidof".
Printable View
When I use the function "system()", it returns number 0, as it is supposed to.
How can I make it to return a string? For example, I want it to return the PID of some process, using the Linux shell command "pidof".
system returns the return value of the program that was called, so it can only be an integer.
I guess you can redirect output of "pidof" (e.g to a file and then read it from there).
Du-oh! How blind I was :D. Thanks.
Or use popen() / pclose(), which saves all the messy temporary file business.