Which one? You probably have localhost, firewire, wifi, and atleast one ethernet.
There's is no surefire way as it's not always clear, to the the software on your machine, which is the correct route out of your system.
One solution is to connect to a server and have it tell you what the client address was. Of course, if you're behind a NAT you'll get the NAT address. http://ip1.dynupdate.no-ip.com/
Check your OS' documentation, there's probably a special header file that is OS specific and also has the function for getting the IP address of one of the interfaces.