Find ip address

hi, I'm trying to write a c++ program in Dev C++, I want it to find the ip Address of a Windows pc, and output it in normal text, I've searched the internet, but none of all the forums and opics seemed to help me much, I'm still not very familiar with C++, but I'm not a beginner, so please can you help me, step by step, on how to write a program to do this?
1. Download the page http://checkip.dyndns.com/
You can use a library such as libcurl or write your own function to do that.

2. Get the string between "Current IP Address:" and the next '<'.
That's the IP address.


If you're looking for your local IP address, there are other ways. But I doubt that's what you want.
Last edited on
Thanks for your quick replies, Athar, can you please specify more in detail the second point in your reply. Oh, and how can I Download the link you gave me, did you mean that somehow I should get it's code( just a guess )? Please reply soon, thanks.
Last edited on
Tenomig wrote:
Oh, and how can I Download the link you gave me, did you mean that somehow I should get it's code( just a guess )?

Yeah, that's pretty much what downloading means.
To do it, refer to the libcurl examples. The two examples "fopen() URL" and "get a remote file in memory only" sound particularly promising.
If you don't want to use libcurl, look for descriptions of the HTTP protocol.

Basically you just need to send this:
GET / HTTP/1.1
Host: checkip.dyndns.com
Connection: close


and strip the HTTP header of the received data.


Tenomig wrote:
Thanks for your quick replies, Athar, can you please specify more in detail the second point in your reply.

Well, the dyndns page looks like this:
<html><head><title>Current IP Check</title></head><body>Current IP Address: xx.xx.xx.xx</body></html>


Since you don't need all that unnecessary stuff, you can determine the position of "Current IP Address:" in the page and then get all characters until the '<' of </body> appears.
You don't need to parse the output from http://ip1.dynupdate.no-ip.com/
Hey Athar,

Do you know of any way to find out the internal ip using dev-C++?

thx in advance!

Thanks all, you help me a lot, if I encounter any problems, I'll send you replies
Do you know of any way to find out the internal ip using dev-C++?

Dev-C++ is not a language, it is an IDE.
For Windows, see:
http://msdn.microsoft.com/en-us/library/ms738520%28v=VS.85%29.aspx

to get the local IP addresses.
The getaddrinfo function exists on other operating systems as well, though.
Please can you include some examples, I'm using the libcurl library, but still I can't manage to create a program that works well.
There are examples on the libcurl website. Look at the ones I named and any others you think might be useful.
Topic archived. No new replies allowed.