#include
#include
#include
int validate_ip (char *a_ipAddr)
{
char *ipByte;
char localIpAddr[20];
int iCounter = 0;
printf("ip address is %s\n",a_ipAddr);
strcpy(localIpAddr,a_ipAddr);
ipByte = strtok (localIpAddr,":");
printf("ip address is %s\n",ipByte);
while (ipByte != NULL)
{
iCounter++;
if(!((atoi(ipByte)>0)&&(atoi(ipByte)<255)))
{
return 0;
}
ipByte = strtok (NULL, ":");
}
if(iCounter!=6)
{
printf("iCounter = %d\n",iCounter);
return 0;
}
else
return 1;
}
main(int argc,char *argv[])
{
if(validate_ip(argv[1]) == 0)
printf("perfect\n");
else
printf("NAAAAAAAAA...\n");
}
~

No comments:
Post a Comment