0

I am beginner to C. I try to make a system call with

int system(const char *command)

and want to read back certain output strings from the screen. Which C function can do this?

For example, if I run:

ping 192.168.0.1 -c 2

I will get something like:

2 packets transmitted, 0 received

on the screen. If I can read back the string, I am able to analyze how many packets were received, etc.

So far I have thought about an awkward solution, ie. make the system call and save the output to a file:

ping 192.168.0.1 -c 2 > output.txt

Then I can use fopen() and fscanf() on output.txt.

Does anyone have any smarter ideas without saving a file? Thank you for help!

0 Answers0