title: Why does strlen() work and my approach doesnt?
body: <p>I have the following function:</p>
  
  <pre><code>void print_out_reversed(char string[])
  {
      int index = strlen(string);
      printf("%i\n", index);
  
      while (string[index] != '\0')
          index--;
  
      for (int i = index; i &gt;= 0; i--)
          putchar(string[i]);
      putchar('\n');
  }
  </code></pre>
  
  <p>This function works fine after I deleted the line</p>
  
  <pre><code>int index = sizeof(string) / sizeof(string[0])
  </code></pre>
  
  <p>and replaced it by</p>
  
  <pre><code>strlen(string)
  </code></pre>
  
  <p>But why? I learned that if you want to find out the length of an array, you have to divide array by array[0]. In my old version he always printed out that the index is eight no matter which string I have entered. I cant figure out why.I know that strlen() ignores the elements after "\0", but suppose that I want the total size of a char array.</p>