c - printf ipv6 address using struct in6_addr and ipv4 address using u_int32_t -
this question has answer here:
- expand ipv6 address can print stdout 2 answers
i want printf
values of ipv6 address type struct in6_addr
, ipv4 address type u_int32_t
console.
i have tried type casting yields error
error: aggregate value used integer expected printf("---------------- ipv4= %zu ipv6 = %zu ",(size_t)ipv4, (size_t)ipv6);
i have tried %s ,%lu
, many other ways after going through old question in stack overflow , other places .
if has solution shall thankful .
in6_addr
struct contains union, can't cast size_t , hope work. should use inet_ntop
convert human-readable form. see http://www.beej.us/guide/bgnet/output/html/multipage/inet_ntopman.html more info.
Comments
Post a Comment