Click here to Skip to main content
15,888,224 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I have coded program using VC++.

I want to get the ip address of my local PC.

First I tried to get that informations by using gethostbyname() in VC++.

But compile error make that:

'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings..

Next I want to use getaddrinfo() instead of gethostbyname(), but failed because I don't know how to use of this getaddrinfo parameters...

Thank you in advance.

What I have tried:

More that 1 day wasted for this error.
Posted
Updated 10-Aug-16 19:17pm

It is all explained in the documentation: getaddrinfo function (Windows)[^].
 
Share this answer
 
Here you can find a complete example (found by google):
Winsock Programmer’s FAQ: Get the Local IP Address(es)[^]
Read the intro at the top and be Aware that one pc can have several IPs.
I hope it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900