hello, i have a bunch of string formatting using sprintf and inet_ntop such as:
Code:
sprintf(tmp, "Message received from: <ip>:%s <port>:%d",
inet_ntop(client->addr.sin_addr),
ntohs(client->addr.sin_port));
(tmp is an adequately sized string where the string gets stored), when doing this i get a compiler warning:
warning: format '%s' expects type 'char *', but argument 3 has type 'int'
i can get rid of this warning by casting inet_ntop() to a char*:
Code:
sprintf(tmp, "Message received from: <ip>:%s <port>:%d",
(char*)inet_ntop(client->addr.sin_addr),
ntohs(client->addr.sin_port));
but this seems weird to me as all the documentation i see that inet_ntop() returns a string. i'm trying to understand why the compiler throws this warning can any one help?
regards,
qualia