C语言 批量ping工具

admin 2021年9月1日14:59:30评论150 views字数 708阅读2分21秒阅读模式

今天上课没听课(咳咳,真心听不懂),然后想想自己好歹买了vpn,翻个墙玩玩多好。
然后,苦于GreenVPN在Linux上没有客户端。。那么,手动建立VPN使可以,但是用那一条线路能够比较快,这是个问题。
一般测试线路都是看Ping值。于是,就开始写C语言的批量Ping工具。
主要思路是这样的。

图表1.png

第一次画流程图,不要在意。。

对于在C语言中如何使用Ping命令,我是用system()来调用系统命令。
因为我不会用管道传输(弱渣),所以只能建立临时文件了。
那么,代码如下:

#include 
#include 
#include 
int main()
{
    char ip[100][30];
    int ping[100];
    FILE *fp;
    FILE *temp;
    int len;
    int c;
    fp=fopen("ip.txt","r");            
    if(fp==NULL)                    //判断是否成功打开ip.txt文件
    {
        puts("Error in opening ip.txt.");
        exit(1);
    }
    for(len=0;!feof(fp);len++)
    {
    fgets(ip[len],30,fp);                //按行读取IP
    char *p=strchr(ip[len],'n');            //去除换行符
    if(p!=NULL)
    *p='';
    }

    for(int t=0;t

FROM :rickyhao.com | rickyhao.com

相关推荐: 打造专属 Cobalt Strike

环境准备 VPS CentOS 8 CobaltStrike4.0 ServerChan SCKEY 配置 VPS 使用dnf安装常用软件 1dnf install vim net-tools wget –y 修改主机名 123echo 'Cathe…

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年9月1日14:59:30
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   C语言 批量ping工具http://cn-sec.com/archives/499755.html

发表评论

匿名网友 填写信息