title: SIGSEGV (Segmentation Fault) in C
body: <p>I get the SIGSEGV - Segmentation Fault on the run-time for the code below when the function (<code>log_msg_send</code>) is called. I read that it is about memory violation but I could not find the reason. I would appreciate for the any suggestions/help. </p>
  
  <pre><code> #define  MAXSTRINGLENGTH 128
  #define BUFSIZE 512
  
  void log_msg_send(char *message, char *next_hop);
  
  struct routing {
          int hop_distance;
          char sender_ID[16]; 
  };
  
  struct routing user_list[40]  =  { [0]={0,0,0,0}};
  
  
  int main(int argc,char *argv[]){
      strcpy(user_list[0].sender_ID,"192.168.001.102");
      char message[1000];
      strcpy(message,"123456123456");
       log_msg_send(message, user_list[0].sender_ID);
  
      return 0;
  }
  
  void log_msg_send(char *message, char *next_hop){
      char *SRV_IP;
      strcpy(SRV_IP,  next_hop);
  
      if (sizeof(SRV_IP) == 16){
           struct sockaddr_in si_other;
           int s, i, slen=sizeof(si_other);
           char buf[60] ;
           strcpy(buf, message);
  
          if ((s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1){
            fprintf(stderr, "socket() failed \n");
            exit(1);
          }
  
          memset((char *) &amp;si_other, 0, sizeof(si_other));
          si_other.sin_family = AF_INET;
          si_other.sin_port = htons(33333);
          if (inet_aton(SRV_IP, &amp;si_other.sin_addr) == 0) {
            fprintf(stderr, "inet_aton() failed \n");
            exit(1);
          }
  
            if (sendto(s, buf, BUFSIZE, 0,(struct sockaddr *) &amp;si_other, slen)==-1){
            fprintf(stderr, "sendto() failed \n");
            exit(1);
          }
  
          close(s);
      }
  }
  </code></pre>
  
  <p>PS. For the people who have the SIGSEGV problem. Most <a href="http://en.wikipedia.org/wiki/Segmentation_fault#Common_causes" rel="nofollow">common reasons</a> for SIGSEV problem: 
   -   attempting to execute a program that does not compile correctly. Note that most compilers will not output a binary given a compile-time error.
   -   a buffer overflow.
   -   using uninitialized pointers.
   -   dereferencing NULL pointers.
   -   attempting to access memory the program does not own.
   -   attempting to alter memory the program does not own (storage violation).
   -   exceeding the allowable stack size (possibly due to runaway recursion or an infinite loop)</p>