title: Reverse char array with pointer in C
body: <p>I want to reverse a char array using pointers, but all I get when I <code>printf</code> the pointer is <code>null</code>. I don't know what I'm doing wrong or how to fix it. So how can I reverse the string in a similar way?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void reverse(char *cstr);
  
  int main()
  {
      char a[100];
      char *p = a;
      printf("geef een string ");     // ask user to write a word
      scanf("%s", &amp;a);
  
      reverse(p);
  
      printf("%s", *p);
  }
  
  
  void reverse(char *p)
  {
      int i = 0;
      char temp;
      int lengte;
  
      for(i = 0; *(p+i) != '\0'; i++)
      {
          lengte++;                        // length of char array without the '\0'
      }
  
      for(i = 0; i &lt; lengte; i++)
      {
          temp = p[i];               // something goes wrong here but I don't know  what
          p[i] = p[lengte-i];
          p[lengte-i] = tem;
      }
  }
  </code></pre>
  
  <p>Something goes wrong at the</p>
  
  <pre><code>p[i] = p[lengte-i];
  p[lengte-i] = tem;
  </code></pre>
  
  <p>part. What do I need to change it to?</p>