c语言+字符串操作函数大全,C语言基础 第九章 常用字符串操作函数

#include#include#include#includetypedefstruct{char hostClass[8];char hostMAC[20];char hostDHCPName[70];char hostDevName[70];char hostIP[20];char hostConnectInterface[8];char hostOnlineTime[64];char hostStotageAccessStatus[8];

}CMCCLanHostInfo;int main(void)

{

FILE*fp =NULL;char line[512] = {0};int i=0;struct tm timeinfo={0};

CMCCLanHostInfo tmp_lhi={0};char if_mac[20]={0};char contype[20]={0};char conssid[20]={0};char ip_addressing[20]={0};char time[128] ="";char *p =NULL;char dest[] = "[]";if ((fp = fopen("pclist_info", "r")) ==NULL) {

printf("%s", "Cannot open pclist_info file!\n");return 0;

}if(fgets(line, sizeof(line)-1 , fp) !=NULL )

{

line[strlen(line)-1] = ‘\0‘;//90:2b:34:67:2b:43 [192.168.10.111] [0] [1] [0 1900/01/00 00:00:00] [Wire] [STATIC] [Online]

sscanf(line, "%[^]%*[^[][%[^]] %*[^[][%[^]] %*[^[][%[^]] %*[^[][%[^]] %*[^[][%[^]] %*[^[][%[^]] %*[^[][%[^]] %*[^[][%[^]] %*[^[][%[^]] %*[^[][%[^]]",

tmp_lhi.hostMAC,

tmp_lhi.hostIP,

tmp_lhi.hostDevName,

tmp_lhi.hostDHCPName,

time,

contype,

ip_addressing,

tmp_lhi.hostClass,

tmp_lhi.hostConnectInterface,

conssid,

tmp_lhi.hostStotageAccessStatus);

printf("hostMAC = %s \n",tmp_lhi.hostMAC);

printf("hostIP = %s \n",tmp_lhi.hostIP);

printf("hostDevName = %s \n",tmp_lhi.hostDevName);

printf("hostDHCPName = %s \n",tmp_lhi.hostDHCPName);

printf("time = %s \n",time);

printf("contype = %s \n",contype);

printf("ip_addressing = %s \n",ip_addressing);

printf("hostClass = %s \n",tmp_lhi.hostClass);

printf("hostConnectInterface = %s \n",tmp_lhi.hostConnectInterface);

printf("conssid = %s \n",conssid);

printf("hostStotageAccessStatus = %s \n",tmp_lhi.hostStotageAccessStatus);

}

fclose(fp);return 0;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值