I want to write a C or C++ program, that given an IP address, Pings it and then performs further action based on whether the Ping was successful or not. How to do this?
I want to write a C or C++ program, that given an IP address, Pings it and then performs further action based on whether the Ping was successful or not. How to do this?
#include <iostream>
using namespace std;
int main() {
int x = system("ping -c1 -s1 8.8.8.8 > /dev/null 2>&1");
if (x==0){
cout<<"success";
}else{
cout<<"failed";
}
replace 8.8.8.8 from your IP Address