Hi, through looking at these forums I found a program that gets the internal machine name and IP address.
Problem is I only need the IP.
How would I modify this code to only get the IP?
#include <winsock.h> /* for socket(),... */
#include <windows.h>
cheersCode:char* get_local_ip() { char abc[MAX_PATH]; WSADATA wsaData; SOCKET sockfd; WSAStartup(MAKEWORD(2, 0),&wsaData); sockfd=socket(AF_INET,SOCK_STREAM,0); struct sockaddr_in sa; struct hostent *hp; gethostname(abc, sizeof(abc)); puts(abc); hp = gethostbyname(abc); sa.sin_family = hp->h_addrtype; memcpy(&sa.sin_addr, hp->h_addr, sizeof(sa.sin_addr)); return inet_ntoa(sa.sin_addr); }



LinkBack URL
About LinkBacks



