title: Stucking in the pointer swap loop in c
body: <p>I'm trying to learn C right now and there is an example which doesn't let me use <code>string.h</code> or other functions.</p>
  
  <p>For example, I need to reverse string with pointers.</p>
  
  <p>But when I swap, it's stuck.</p>
  
  <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt;
  
  void reverseCopy( char *, char *, int);
  
  int main(){
      char *word1 = "Welcome to the C programming";
      char word2[50];
      int i,count;
  
      for(i=0;i&lt;50;i++){
          if(word1[i]=='\0') break;
          count++;
      }
  
      reverseCopy(word1,word2,count);
  
      return 0;
  }
  
  void reverseCopy( char * g1, char * g2 ,int lenght){
      g2=g1;
      char temp;
      int i;
      int j=temp-1;
  
      for(i=0;i&lt;j/2;i++){
          temp=*(g2+i);
          *(g2+i)=*(g2+j-i);
          *(g2+j-i)=temp;
      }
  
      puts(g2);
  }
  </code></pre>