The question is about looping through the following structure
ive seen people useCode: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 */ };
andCode://with pointers for( char const*const* alias = hp->h_aliases; *alias != NULL; ++alias
When you use a for loop using pointers this case, why is the person explicit about NULL, but with indexing, it's implicit? ie not usingCode:// with indexing for( int i=0; hp->h_aliases[i]; ++i)
hp->h_aliases[i] != 0



LinkBack URL
About LinkBacks


