title: Checking for duplicate words in a string in C
body: <p>I have written a code in c to search for duplicate words in a string, It just appends every word in a string to a 2d string array, but it is returning 0 for the numbers of rows and duplicate strings, what is the problem with the code?</p>
  <pre class="lang-c prettyprint-override"><code>int main() {
    char str[50] = &quot;C code find duplicate string&quot;;
    char str2d[10][50];
  
    int count = 0;
    int row = 0, column = 0;
  
    for (int i = 0; str[i] != '\0'; i++) {
      if (str[i] != '\0' || str[i] != ' ') {
        str2d[row][column] = str[i];
        column += 1;
      } else {
        str2d[row][column] = '\0';
        row += 1;
        column = 0;
      }
    }
  
    for (int x = 0; x &lt;= row; x++) {
      for (int y = x + 1; y &lt;= row; y++) {
        if (strcmp(str2d[x], str2d[y]) == 0 &amp;&amp; (strcmp(str2d[y], &quot;0&quot;) != 0)) {
          count += 1;
        }
      }
    }
  
    printf(&quot;%i %i&quot;, row, count);
  
    return 0;
  }
  </code></pre>