#include <arpa/inet.h>
char buf[INET6_ADDRSTRLEN] = {};
int af = AF_INET;
unsigned char addr[4] = {0x7f, 0x0, 0x0, 0x1};
printf("Address: %s\n", inet_ntop(af, addr, buf, sizeof buf));
Is it valid to pass unsigned char
array to inet_ntop()
call? The code above works, but the man page says API expects network address structure in the second argument.