fork download
  1. #if defined(__MINGW32__)
  2. #define _WIN32_WINNT 0x0501
  3. #include <ws2tcpip.h>
  4. #else
  5. #include <netdb.h>
  6. #endif
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10.  
  11. int main(int argc, char **argv) {
  12. char hostname[1024];
  13. struct addrinfo *info;
  14. struct addrinfo hints;
  15.  
  16. memset(&hints, 0, sizeof(struct addrinfo));
  17. hints.ai_flags = AI_CANONNAME;
  18.  
  19. #if defined(__MINGW32__)
  20. WSADATA wsaData;
  21. WSAStartup(0x0202, &wsaData);
  22. #endif
  23.  
  24. if (gethostname(hostname, 256) == 0 && getaddrinfo(hostname, NULL, &hints, &info) == 0) {
  25. printf("%s\n", info->ai_canonname);
  26. return EXIT_SUCCESS;
  27. }
  28. return EXIT_FAILURE;
  29. }
  30.  
Success #stdin #stdout 0s 2552KB
stdin
Standard input is empty
stdout
checker.checker