69,374
社区成员
发帖
与我相关
我的任务
分享
#include <stdlib.h>
#include <string.h>
typedef struct
{
char ip_add[20];
char port[10];
char ttl[10];
}IP_INFO;
void main()
{
IP_INFO ip_info;
char *ip;
memset(&ip_info, '\0', sizeof(ip_info));
ip = "10.10.143.123/8000/100";
sscanf(ip, "%[^/]/%[^/]/%s", ip_info.ip_add, ip_info.port, ip_info.ttl);
printf("ip address:%s\nport:%s\nttl:%s\n", ip_info.ip_add, ip_info.port, ip_info.ttl);
}
static int hpt(char *h, char *port, unsigned char *ttl)
{
char *s; ///////////////////////////////未指向有效空间
/* 定位端口开始的字符 */
printf("%c",*s);
if (!s)