title: How does this C program to reverse a string using pointers work?
body: <p>would you please explain to me step by step the algorithm of this C program to reverse a string using pointers? </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main()
  
  {
      char str[50];
      char rev[50];
      char *sptr = str;
      char *rptr = rev;
  
      int i=-1;
      printf("Enter any string : ");
      scanf("%s",str);
  
      while(*sptr)
      {
          sptr++;
          i++;
      }
  
      while(i&gt;=0)
      {
          sptr--;
          *rptr = *sptr;
          rptr++;
          --i;
      }
  
  
      *rptr='\0';
      printf("Reverse of string is : %s",rev);
      return 0;
  }
  </code></pre>