Suppress system("ping") output in C++

Samuel picture Samuel · Oct 31, 2010 · Viewed 10k times · Source

I have written a simple program that pings three sites and then reacts to whether they are reachable or not.

My question is: can I suppress system("ping ")'s output? I have written my code in C++ as I know that language the best. Currently the code opens the ping.exe running the system command. If I can prevent the output from showing up while it still pings that would be ideal.

I am eventually going to turn this program in a windows service that is why I would like to suppress both the command line console window as well as suppress the ping output. Thanks.

Answer

zvrba picture zvrba · Oct 31, 2010

Try doing system("ping host > nul") (nul is windows equivalent of UNIX /dev/null).