Hostent returning null from char* . Works with hardcoded address

91 Views Asked by At

people.

I know hostent is deprecated but have to use it for a project.

For some reason if I do this...

hp = getbyhostname ("www.google.com");

hp works all right.

But then, if I do this:

char *addre;
addre = someFunction();
printf ("The address is %s", addre);
hp = gethostbyname (addre);

where someFunction() returns a char*, printf works fine and displays the address correctly, but hp returns null.

Any suggestions?

Thanks.

0

There are 0 best solutions below