I posted a question about this maybe a two days ago. I realized I don't understand the constructions. Let me rattle on.
Given the structure
Code:
struct hostent {
char *h_name; /* official name of host */
char **h_aliases; /* alias list */
int h_addrtype; /* host address type */
int h_length; /* length of address */
char **h_addr_list; /* list of addresses from name server */
#ifndef _POSIX_C_SOURCE
#define h_addr h_addr_list[0] /* address, for backward compatiblity */
#endif /* !_POSIX_C_SOURCE */
};
h_aliases can get retrieved using either
Code:
//with pointers
for( char const*const* alias = hp->h_aliases;
*alias != NULL;
++alias)
or
Code:
// with indexing
for( int i=0;
hp->h_aliases[i];
++i)
I just realized I don't understand the pointer constructions for either
// with indexing
hp->h_aliases[i];
or
char const*const* alias = hp->h_aliases;
That is, I don't know how they derived this. Can someone break this down into laymans terms or at least point in the right direction on how they got this?