One of the more difficult concepts to grasp, for me, are pointers and type casting. For instance, I don't know WHY it's possible to cast struct sockaddr_in to struct sockaddr when working with winsock, other than because I'm told I have to.
If possible, can someone break down the next few lines of code to me in lamemen's (sp?) terms for me? I'll attempt to, but I'll no doubt be way off...
hostent* localHost; //LINE 1
char* localIP; //LINE 2
localHost = gethostbyname(""); //LINE 3
localIP = inet_ntoa (*(struct in_addr *)*localHost->h_addr_list); //LINE 4
LINE 1: declares a null pointer of type hostent
LINE 2: delcares a null pointer of type char
LINE 3: localHost now points to an address in memory... somewhere.
LINE 4: Totally lost. Dereferencing localHost.h_addr_list[0], casting it to struct in_addr *, then dereferencing that again? Why not (struct in_addr)*localHost->h_addr_list other than because it won't work?