#include <iostream.h>
#include <winsock.h>

int doit(int, char **)
{
    char ac[80];
    if (gethostname(ac, sizeof(ac)) == SOCKET_ERROR) {
        cerr << "Error " << WSAGetLastError() <<
                " when getting local host name." << endl;
        return 1;
    }
    cout << "Host name is " << ac << "." << endl;

    struct hostent *phe = gethostbyname(ac);
    if (phe == 0) {
        cerr << "Yow! Bad host lookup." << endl;
        return 1;
    }

    for (int i = 0; phe->h_addr_list[i] != 0; ++i) {
        struct in_addr addr;
        memcpy(&addr, phe->h_addr_list[i], sizeof(struct in_addr));
        cout << "Address " << i << ": " << inet_ntoa(addr) << endl;
    }

    return 0;
}

int main(int argc, char *argv[])
{
    WSAData wsaData;
    if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
        return 255;
    }

    int retval = doit(argc, argv);

    WSACleanup();

    return retval;
}


//--------------------------------------------------------------------


Перебираем все IPv4 интерфейсы:

#include <IpHlpAPI.h>
#include <Winsock2.h>
...
void enumIPv4Interfaces()
{   
    ULONG sz = 0;
    PMIB_IPADDRTABLE tbl = NULL;
    DWORD ret = ::GetIpAddrTable(tbl, &sz, TRUE);

    if(NO_ERROR != ret && ERROR_INSUFFICIENT_BUFFER != ret)
    {
        //log error
        return;
    }

    tbl = (PMIB_IPADDRTABLE) GlobalAlloc(GHND, sz);

    if(NULL == tbl)
    {
        //log error
        return;
    }

    ret = ::GetIpAddrTable(tbl, &sz, TRUE);

    if(NO_ERROR != ret)
    {
        //log error
        GlobalFree(tbl);
        return;
    }

    for(size_t i = 0; i<tbl->dwNumEntries; ++i)
    {
        in_addr addr;
        addr.S_un.S_addr = tbl->table[i].dwAddr;

        char* ch = ::inet_ntoa(addr);

        if(NULL == ch)
        {
            //log error
            continue;
        }

        //в ch очередной IP адрес
    }

    GlobalFree(tbl);
}