Вопрос

From the "man" pages it looks like inet_ntop returns a string (const char*) which should be alright when comparing to NULL. However, in my program I get a compiler warning at the first line in this code block that says:

warning: comparison between pointer and integer

. Assuming the correct parameters are being passed in, is there something wrong with this:

    if(inet_ntop(address->sa_family, numericAddress, addrBuffer, sizeof(addrBuffer)) == NULL)
    {
        fputs("invalid address", stream);
    }

Unfortunately I can't distinguish which one it sees as a pointer and which one it sees as an integer. Thanks in advance!

Это было полезно?

Решение

Have you included the "arpa/inet.h" file?

The "arpa/inet.h" contains inet_ntop declarations. If you do not include it, the compiler will assue inet_ntop returns an int.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top