'&&str[1]=='0'&&str[2]!='.') //判断第一个数是否为零开头的,例如 099.111.111.111
{ }
for(i=0;i<16;i++) {
printf(\return 0;
if(str[i]=='.'&&str[i+1]=='0'&&str[i+2]!='.'&&str[i+2]!='\\0'&&str
[i+2]!=' '&&str[i+2]!='/')
{ //1.
避免出现111.011.022.033的子网地址
printf(\
return 0;
} else
if(str[i]=='.'&&str[i+1]=='\\0'||str[i]=='
'&&str[i+1]=='0'&&str[i+2]!='.'||str[i]=='.'&&str[i+1]==' ')
{ //2.
避免最后一个数字是零的情况下以空格结尾判断失误
printf(\避
免最后出现类似 1.1.1.1..地址
return 0; //4.避
免类似\地址
}
printf(\
}
)
} else { }
//判断掩码合法性 q=Mask_judge(a); if(e>=q&&e<=31)
printf(\掩码合法: %d\\n\
printf(\return 0;
else if(e printf(\掩码非法: %d小于%d\\n\ else if(o!=1) //判断ip地址是否正确 printf(\斜杠只能出现一次!\\n\printf(\掩码非法: %d>31\\n\ if((f>=0&&f<=255)&&(g>=0&&g<=255)&&(h>=0&&h<=255)&&(i>=0&&j<=255) { if(str[z]=='0'&&str[z+1]!='.'||str[z]==' '&&str[z+1]=='0'&&str[z+2]!='.') //判断第一个数是否为零开头的,例如 099.111.111.111 { } for(i=z;i printf(\return 0; if(str[i]=='.'&&str[i+1]=='0'&&str[i+2]!='.'&&str[i+2]!='\\0'&&str [i+2]!=' ') { //1. 避免出现111.011.022.033的错误ip地址 printf(\ return 0; } else if(str[i]=='.'&&str[i+1]=='\\0'||str[i]==' '&&str[i+1]=='0'&&str[i+2]!='.'||str[i]=='.'&&str[i+1]==' ') { //2. 避免最后一个数字是零的情况下以空格结尾判断失误 printf(\避 免最后出现类似 1.1.1.1..地址 return 0; //4.避 免类似\地址 } } } printf(\ else { } //判断ip_add是否属于子网 a2=atoi(itoa(a, str2, 2)); b2=atoi(itoa(b, str2, 2)); c2=atoi(itoa(c, str2, 2)); d2=atoi(itoa(d, str2, 2)); printf(\return 0; /* printf(\ printf(\printf(\printf(\f2=atoi(itoa(f, str2, 2)); g2=atoi(itoa(g, str2, 2)); h2=atoi(itoa(h, str2, 2)); j2=atoi(itoa(j, str2, 2)); /* printf(\ printf(\printf(\printf(\num=e/8; mod=8-e%8; divider=pow(10,mod); // printf(\ if(num==1&&f2==a2&&g2/divider==b2/divider) { } printf(\地址属于该子网1!\\n\return 0; else if(num==2&&f2==a2&&g2==b2&&h2/divider==c2/divider) { } printf(\地址属于该子网2!\\n\return 0; else if(num==3&&f2==a2&&g2==b2&&h2==c2&&j2/divider==d2/divider) else /* printf(\ printf(\地址不属于该子网!\\n\ { } printf(\地址属于该子网3!\\n\return 0;