G
games60
Hi,
I want to get the IP address of my machine in my program and for that i
have written the following code.
I don't know why the gethostbyname() is not returning the correct
hostent structure.
hp = new hostent[];
TCHAR str[MAX_COMPUTERNAME_LENGTH+1];
TCHAR result[MAX_COMPUTERNAME_LENGTH+1];
GetComputerName(str,&len);
hp = gethostbyname(str);
if(hp!=NULL)
{
memcpy(result, hp->h_name, sizeof(result));
OR
result=(TCHAR*)hp->h_name;
}
The result that i am getting the hp=NULL.
Thanks,
Saurabh Aggrawal
I want to get the IP address of my machine in my program and for that i
have written the following code.
I don't know why the gethostbyname() is not returning the correct
hostent structure.
hp = new hostent[];
TCHAR str[MAX_COMPUTERNAME_LENGTH+1];
TCHAR result[MAX_COMPUTERNAME_LENGTH+1];
GetComputerName(str,&len);
hp = gethostbyname(str);
if(hp!=NULL)
{
memcpy(result, hp->h_name, sizeof(result));
OR
result=(TCHAR*)hp->h_name;
}
The result that i am getting the hp=NULL.
Thanks,
Saurabh Aggrawal