fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define LARGE_INFO_LENGTH 1024
  5.  
  6. enum tt__IPType { tt__IPv4, tt__IPv6 };
  7.  
  8. struct tt__IPAddress
  9. {
  10. enum tt__IPType Type; /* required element of type tt:IPType */
  11. char *IPv4Address; /* optional element of type tt:IPv4Address */
  12. char *IPv6Address; /* optional element of type tt:IPv6Address */
  13. };
  14.  
  15. struct tt__DNSInformation
  16. {
  17. struct tt__IPAddress* DNSManual;
  18. };
  19.  
  20. int main()
  21. {
  22. struct tt__DNSInformation* DNSInformation;
  23. char dns_string[] = "192.168.2.254";
  24.  
  25. DNSInformation = malloc(sizeof(struct tt__DNSInformation));
  26. DNSInformation->DNSManual = malloc(sizeof(struct tt__IPAddress));
  27. DNSInformation->DNSManual->IPv4Address = malloc(sizeof(char) * LARGE_INFO_LENGTH);
  28. strncpy(DNSInformation->DNSManual->IPv4Address, dns_string, LARGE_INFO_LENGTH - 1);
  29.  
  30. printf("%s\n", DNSInformation->DNSManual->IPv4Address);
  31. return 0;
  32. }
Success #stdin #stdout 0s 2424KB
stdin
Standard input is empty
stdout
192.168.2.254