title: Segmentation fault with strcpy() with array of pointers to structures
body: <p>Constants:</p>
  
  <pre><code>#define MAX_OPCODE_NAME_LEN 4
  </code></pre>
  
  <p>I have an array of structs:</p>
  
  <pre><code>OPCODE *mot[NUM_OPCODES];
  </code></pre>
  
  <p>Struct def:</p>
  
  <pre><code>typedef struct opcode {
  char name[MAX_OPCODE_NAME_LEN + 1];
  char format;
  int type;
  } OPCODE;
  </code></pre>
  
  <p>In my code:</p>
  
  <pre><code>strcpy(mot[0]-&gt;name, "hlt");
  strcpy(mot[1]-&gt;name, "add");
  strcpy(mot[2]-&gt;name, "sub"); // seg fault on this command
  strcpy(mot[3]-&gt;name, "mul");
  // ...more code follows
  </code></pre>
  
  <p>My code gives me a segmentation fault here and I'm not sure why, since it should have enough space to hold 5 characters (4 char followed by '\0'), so it shouldn't be running out of space, and I'm just copying a string literal into a static memory location. Perhaps I defined the struct incorrectly or used the pointer arrow in the wrong spot?</p>