views:

62

answers:

2

Hello,

I have an IP address stored in in_addr_t and I want to create the string representation of this data type, ie in_addr_t to 10.0.0.1.

How can I do that?

+1  A: 

Try inet_ntop

as documented here:- manpagez

James Anderson
inet_ntop takes const void *restrict src as argument. My type is in_addr_t. How can I convert between the two of them?
cateof
@cateof: You can simply pass the address of your `in_addr_t` variable as the `src` argument, with `AF_INET` as the `af` argument.
caf
A: 

char *inet_ntoa(struct in_addr in);
is the desired function.

bhups
inet_ntoa() seems to be considered deprecated.
unwind