title: Why is strcmp returning -1?
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  char passage[5000][20];
  char *getword(int i);
  
  int main(){
      passage[0][0] = 'a';
      passage[0][1] = 'm';
      passage[0][2] = '\0';
      printf("%s\n", getword(0));
      char *word = getword(0);
      printf("%d", strcmp(word,"am"));
      return 0;
  }
  
  char *getword(int i){             //get a word from passage
      int a=0;
      static char words[20];
      while (passage[i][a] != ' '){
          words[a] = passage[i][a];
          a++;
          //printf("%c\n",words[a]);
      }
  
      words[a] = '\0';
  
      return words;
  }
  </code></pre>
  
  <p>I am planning to make a <code>function</code> for <code>string</code> comparing by getting a <code>string</code> from 2d <code>array</code> with the index and compare the <code>string</code> with some word. Why is the <code>strcmp</code> returning -1? It should be the same or did it take <code>null</code> into consideration as well?</p>