(WinAPI) IP SAVER



  • Hi

    Wer weiss wie der Code complett ausehen würde

    #include <iostream.h>
    #include <conio.h>

    #define NUM_ELEMENTS(x) (sizeof((x)) / sizeof((x)[0])) // Für IP auslesen
    BOOL IP_auslesen(char* IP_ADRESSE)
    {
    struct hostent* h;
    WSADATA wsaData;
    UCHAR ucAddress[4];
    CHAR szHostName[MAX_PATH];
    int x;

    WSAStartup(MAKEWORD(1, 1), &wsaData);
    if(SOCKET_ERROR != gethostname(szHostName, NUM_ELEMENTS(szHostName)))
    {
    if(NULL != (h = gethostbyname(szHostName)))
    {
    for(x = 0; (h->h_addr_list[x]); x++)
    {

    ucAddress[0] = h->h_addr_list[x][0];
    ucAddress[1] = h->h_addr_list[x][1];
    ucAddress[2] = h->h_addr_list[x][2];
    ucAddress[3] = h->h_addr_list[x][3];

    wsprintf(IP_ADDRESSE, "%d.%d.%d.%d", ucAddress[0], ucAddress[1], ucAddress[2], ucAddress[3]);
    }
    }
    }
    WSACleanup();

    return TRUE;
    }

    int main()
    {

    }



  • Wie war die Frage ?



  • Bei mir läuf er nicht.

    Danke



  • Bei mir läuf er nicht.

    Das ist immer nach wie vor keine Frage.

    Es wäre fein, wenn du mal dein Problem schildern würdest anstatt hier nur Code zu posten.

    Sieht für mich auf jeden Fall nicht nach einem Standard-C++ Problem aus.



  • übertrieben, das wegzuschieben. der fehler war ja offensichtlich die leere main. die tut auch in standard-c++ nix.

    ist ja auch logisch.

    int main()
    {
    chat ip[17];
    IP_auslesen(ip);
    printf("%s",ip");
    return 0;
    }
    

Anmelden zum Antworten