Advertisement
Guest User

Untitled

a guest
Mar 10th, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.85 KB | None | 0 0
  1. C:\Codes>more ip_address_test.c
  2. #include <stdio.h>
  3.  
  4. int main(void)
  5. {
  6.       unsigned char a,b,c,d;
  7.       scanf("%hhu.%hhu.%hhu.%hhu", &a,&b,&c,&d);
  8.       printf("%hhu\t%hhu\t%hhu\t%hhu\t", a, b, c, d);
  9.       return 0;
  10. }
  11.  
  12. // https://stackoverflow.com/questions/19558013/ip-address-input-in-c
  13.  
  14. C:\Codes>
  15.  
  16. C:\Codes>gcc -Wall ip_address_test.c -o ip_address_test
  17. ip_address_test.c: In function 'main':
  18. ip_address_test.c:6:13: warning: unknown conversion type character 'h' in format [-Wformat=]
  19.        scanf("%hhu.%hhu.%hhu.%hhu", &a,&b,&c,&d);
  20.              ^
  21. ip_address_test.c:6:13: warning: unknown conversion type character 'h' in format [-Wformat=]
  22. ip_address_test.c:6:13: warning: unknown conversion type character 'h' in format [-Wformat=]
  23. ip_address_test.c:6:13: warning: unknown conversion type character 'h' in format [-Wformat=]
  24. ip_address_test.c:6:13: warning: too many arguments for format [-Wformat-extra-args]
  25. ip_address_test.c:7:14: warning: unknown conversion type character 'h' in format [-Wformat=]
  26.        printf("%hhu\t%hhu\t%hhu\t%hhu\t", a, b, c, d);
  27.               ^
  28. ip_address_test.c:7:14: warning: unknown conversion type character 'h' in format [-Wformat=]
  29. ip_address_test.c:7:14: warning: unknown conversion type character 'h' in format [-Wformat=]
  30. ip_address_test.c:7:14: warning: unknown conversion type character 'h' in format [-Wformat=]
  31. ip_address_test.c:7:14: warning: too many arguments for format [-Wformat-extra-args]
  32.  
  33. C:\Codes>
  34.  
  35.  
  36. C:\Codes>dir ip_address_test.*
  37.  
  38.  Directory of C:\Codes
  39.  
  40. 03/11/2018  09:34 PM               257 ip_address_test.c
  41. 03/11/2018  09:34 PM            30,513 ip_address_test.exe
  42.                2 File(s)         30,770 bytes
  43.  
  44. C:\Codes>
  45.  
  46. C:\Codes>ip_address_test.exe
  47. 8.8.8.8
  48. 0       0       0       8
  49. C:\Codes>
  50.  
  51. C:\Codes>ip_address_test.exe
  52. 192.168.1.1
  53. 0       0       0       1
  54. C:\Codes>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement