#include
#include
int FuncIpAddrToNum(unsigned char *ipTobeConverted);
int main()
{
unsigned int ipNum=0;
unsigned char ipaddr[13]={'\0'};
printf("enter a ip address to conver - ");
scanf("%s",(char*)ipaddr);
ipNum = FuncIpAddrToNum(ipaddr);
printf("\n%x == %s\r\n",ipNum,ipaddr);
return 0;
}
int FuncIpAddrToNum(unsigned char *ipTobeConverted)
{
unsigned int lReturn=0;
unsigned char temp=0;
int index = 0;
for(index=0;index
if(ipTobeConverted[index] == '.')
{
lReturn = (lReturn<<8) + temp;
temp = 0;
}
else
{
temp = temp * 10 + ipTobeConverted[index] - 48;
printf("%d temp \n",temp);
}
}
lReturn = (lReturn<<8) + temp;
return lReturn;
}
No comments:
Post a Comment
తెలుగులో వ్రాయడానికి http://www.google.com/ime/transliteration/ ఉపయోగించండి.