#include <stdio.h>
#include <string.h>
int main()
{
system("ping 112.24.234.47 -c 4 |grep 'Unreachable' > 1.txt");
FILE* fp = fopen("1.txt","r");
char ch = fgetc(fp);
if(EOF == ch)
{
printf("可以联网\n");
}
else
{
printf("不能上网\n");
}
system("rm -rf 1.txt");
fclose(fp);
return 0;
}
转载于:https://my.oschina.net/HappyTeemo/blog/1558428