标签:code std please lease span %s IV put col
1 #include <iostream> 2 using namespace std; 3 4 int main() 5 { 6 char *IP; 7 int ip1, ip2, ip3, ip4; 8 unsigned long result = 0; 9 printf("Please input IP: "); 10 scanf("%s", IP); 11 sscanf(IP, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4); 12 if(ip1 > 255 || ip2 > 255 || ip3 > 255 || ip4 > 255) 13 { 14 printf("Input IP is wrong!\n"); 15 return 0; 16 } 17 result = ip1 * 256 * 256 * 256 + ip2 * 256 * 256 + ip3 * 256 + ip4; 18 printf("The decimal IP is: %u.\n", result); 19 return 0; 20 } 21
标签:code std please lease span %s IV put col
原文地址:https://www.cnblogs.com/hoy0a1d/p/9170422.html