Hello.....
I've written this simple C program to return the IP of a hostname ... this program compiles perfectly as well the Output is built...however, on executing the output, the Output crashes..... Can someone tell me what's the problem?
Regards.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
#include <winsock.h>
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "wsock32.lib")
#pragma comment(lib, "advapi32.lib")
void main()
{
struct hostent *he;
char *addr;
addr = "www.google.com";
he = gethostbyname(addr);
printf("%s", he -> h_name);
getchar();
}
<< moderator edit: added code tags: [code][/code] >>
Edit/Delete Message