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".
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).
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
Du-oh! How blind I was . Thanks.
Or use popen() / pclose(), which saves all the messy temporary file business.
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.