title: Allocating memory for a char pointer that is part of a struct
body: <p>im trying to read in a word from a user, then dynamically allocate memory for the word and store it in a struct array that contains a char *.  i keep getting a  implicit declaration of function âstrlenâ so i know im going wrong somewhere.</p>
  
  <pre><code>struct unit
  {
    char class_code[4];
    char *name;
  };
  
  char buffer[101];
  struct unit units[1000];
  
  scanf("%s", buffer);
  
  units[0].name = (char *) malloc(strlen(buffer)+1);
  strcpy(units[0].name, buffer);
  </code></pre>