I'm working with this structure in C:
/** This structure describes an Internet host address. */
typedef struct pj_hostent
{
char *h_name; /**< The official name of the host. */
char **h_aliases; /**< Aliases list. */
int h_addrtype; /**< Host address type. */
int h_length; /**< Length of address. */
char **h_addr_list; /**< List of addresses. */
} pj_hostent;
I can access the h_name
part of the structure fine like this:
strcpy(test1, he->h_name); // copy part of struct into char[] array
and it contains a meaningful "sip2" value. However, when I try to access the elements of h_addr_list
like this:
strcpy(test1, he->h_addr_list[0]);
I get meaningless jibberish.
What's the correct way in C to access values like this?