c - net_ntoa, struct sockaddr_in and pointer cast -


for third line in following snippet:

char cli_ip[20]; struct sockaddr cliaddr; ....... memcpy(cli_ip, inet_ntoa(((struct sockaddr_in *)cliaddr)->sin_addr), 20); 

i got errors:

udp_receiver.c:96:41: error: cannot convert pointer type udp_receiver.c:96:41: warning: passing argument 2 of ‘memcpy’ makes pointer integer without cast [enabled default] /usr/include/string.h:44:14: note: expected ‘const void * restrict’ argument of type ‘int’

what reason this?

have included headers appropriately?

man of inet_ntoa suggests following include

#include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> 

it might case compiler not find prototype of inet_ntoa , assumes returns int , gives warning in memcpy.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -