Inet_aton IPv4 address normalization

doesn't inet_aton mean to normalize the dotted version of an internet address? Why do I get different output values ​​for the example below?

 int main(){ char USER_IP[16] = "192.168.002.025"; char USER_IP2[16] = "192.168.2.25"; struct sockaddr_in addr; struct sockaddr_in addr2; inet_aton(USER_IP2, &addr.sin_addr); inet_aton(USER_IP, &addr2.sin_addr); printf("addr.sin_addr:%lu\n", addr.sin_addr); printf("addr2.sin_addr:%lu\n", addr2.sin_addr); return 0; } 

exit:

 addr.sin_addr:419604672 addr2.sin_addr:352495808 
+7
source share
1 answer

from the documentation

point address components can be specified in decimal, octal (with leading 0) or hexadecimal, with leading 0X)

it means that

 char USER_IP[16] = "192.168.002.025"; 

means 192 168 2 (25 Octal == 21) and

 char USER_IP2[16] = "192.168.2.25"; 

means 192 168 2 25

+12
source

All Articles