Follow the source code ...
#define _WIN32_WINNT 0x0501
#include <stdio.h>
#include <ws2tcpip.h>
#include <winsock.h>
#include <windows.h>
WSADATA data;
struct addrinfo tips, *information;
void exaple_one(void);
void exaple_two(void);
void main(void) {
printf("chamando o exemplo dois\n");
exaple_two();
printf("chamando o exemplo um = ERROR\n");
exaple_one();
}
void exaple_one(void) {
struct addrinfo tips, *information;
WORD wRequestedVersion = MAKEWORD(1, 1);
int iResult = WSAStartup(wRequestedVersion, &data);
char localaddr[255];
if(iResult == SOCKET_ERROR) {
printf("Error...!");
}
getaddrinfo("www.netflix.com", NULL, &tips, &information);
struct addrinfo *ponteiro;
ponteiro = information;
getnameinfo(ponteiro->ai_addr, ponteiro->ai_addrlen, localaddr, sizeof(localaddr), NULL, 0, NI_NUMERICHOST);
printf("exaple one address = %s\n", localaddr);
}
void exaple_two(void) {
WORD wRequestedVersion = MAKEWORD(1, 1);
int iResult = WSAStartup(wRequestedVersion, &data);
char localaddr[255];
if(iResult == SOCKET_ERROR) {
printf("Error...!");
}
getaddrinfo("www.netflix.com", NULL, &tips, &information);
struct addrinfo *ponteiro;
ponteiro = information;
getnameinfo(ponteiro->ai_addr, ponteiro->ai_addrlen, localaddr, sizeof(localaddr), NULL, 0, NI_NUMERICHOST);
printf("example two address = %s\n", localaddr);
}
If you compile and run the above program will you see that the one example function for running the program could someone explain to me why this occurs?