I write a program which takes IP address as an argument and i wanted to store this IP address in the unit32_t. I can easily convert uint32_t to back to character array. How to convert IP address in Char Array to uint32_t.
For example
./IPtoCHAR 1079733050
uint32_t to IP Address => 64.91.107.58
But how to write a program that does the reverse task?
./CHARtoIP 64.91.107.58
for the first IPtoCHAR, it is
unsigned int ipAddress = atoi(argv[1]);
printf("IP Address %d.%d.%d.%d \n",((ipAddress >> 24) & 0xFF),((ipAddress >> 16) & 0xFF),((ipAddress >> 8) & 0xFF),(ipAddress & 0xFF));
But all these below does not work
uint32_t aa=(uint32_t)("64.91.107.58");
uint32_t aa=atoi("64.91.107.58");
uint32_t aa=strtol("64.91.107.58",NULL,10);