I am trying to write a C++ function to do a ping on a known IP address and then parse the output to see if "1 packet transmitted, 1 received..." is printed.

I am new to this kind of programming and these commands and using Linux.

I am thinking something along the lines of

system("ping IP_ADDR_DEFINE -c 1");

to start with , but don't to where to go from here to save the output and parse the output.

Any help would be greatly appreciated.