i trying make a custom method what causes return a char with system output.
the pseudocode like this.
char *my_Out(char *in ){
in = system ("ping %s",in);
return in;
}
thanks for the help.
You can use popen
, which returns you a stream that you can read the output from. By reading until end-of-file, into a string (probably one that dynamically grows as necessary), you can implement what you're asking for.
A few things
system()
is not a printf style function. You'll need to use sprintf()
to create your argument before.system()
's return value is an int, non a charWhat are you trying to do? It looks like all this function does is run ping
(which, without the -c argument, will never finish running on linux).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With