Possible Duplicate:
Arrow operator (->) usage in C
I am new to C, and I am trying to understand this function (see below).
The main parts that are confusing me are:
sp->s_port = htons(SP->s_port); 
and
p = sp->s_port;
I'm not sure I understand the -> operator.
Here is the whole function... HOSTBUFFERLENGTH is set to 1024 (not sure if that matters)
int gi_get_port (char *serv, char *prot)
/* obtain the port for the named service */
{
  int p, s;
  /* Data for resolving service name to a socket description. */
  struct servent *sp = NULL;
  char            GSBN_servbuf[HOSTBUFFERLENGTH] = {0};                     
   struct servent  GSBN_sp;                                                  
   struct servent *GSBN_serv_result;                                         
   int             GSBN_s = 0;                                               
   GSBN_s = getservbyname_r(serv,                                         
                       prot,                                             
                       &GSBN_sp,                                             
                       GSBN_servbuf,                                         
                       sizeof(GSBN_servbuf),                                 
                       &GSBN_serv_result);                                   
   sp = GSBN_serv_result;                                                    
   sp->s_port = htons(SP->s_port);                                           
   if (sp && SOCKET_DEBUG) {                                                 
      printf("%s GET_SERVICE_BY_NAME - Service: %s Port: %d Protocol: %s\n", 
                 get_timestamp(), sp->s_name, sp->s_port, sp->s_proto);          
       }                                                                         
   if (sp == NULL) {                                                         
      fprintf(stderr, "%s GET_SERVICE_BY_NAME - Service %s not found.\n",    
              get_timestamp(), serv);                                     
   }
  if (sp != NULL) {
    p = sp->s_port;
  } else {
    p = -1;
  };
  return p;
}
 
     
     
    