#include <stdio.h> #include <stdlib.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> char assert_ip(unsigned long ip) { if(!(ip>>31^0x0)) return 'A'; if(!(ip>>30^0x2)) return 'B'; if(!(ip>>29^0x6)) return 'C'; if(!(ip>>28^0xe)) return 'D'; if(!(ip>>27^0xf)) return 'E'; } int main(int argc,char **argv) { unsigned long ip = inet_addr(argv[1]); printf("%x\n",ip); printf("%c\n",assert_ip(htonl(ip))); return 0; }