title: Unable to print words in reverse order
body: <p>I have to print some words in reverse order using pointers.</p>
  
  <p>For example, given "Hello World", output should be "World Hello".</p>
  
  <p>This is what I have done so far, but it doesn't print anything:</p>
  
  <pre><code>void swap(char *ar){
  
      int tmp1[10], tmp2[10], j = 0, k = 0, a, b, z,i; // must use pointers
  
      for (i=0; i&lt;MAX; i++)
      {
          if(ar[i] == ' ')  //if there's a space, store the characters before the space to another array and after the space to another
          {
              for(j = 0; j&lt;i; j++) // tmp1
                  tmp1[j] = ar[j];
  
              for( j = 0; j&lt;MAX-i; j++) //MAX - i would be range of j
                  for(k = i+1; k&lt;MAX; k++) //tmp2
                      tmp2[j] = ar[k];
          }
      }
      i = 0;
      while(1)
      {
          while(tmp2[i] != '\0' &amp;&amp; i&lt;sizeof(tmp2))  // finding the size of tmp2
              a++;
      }
      for(j=0; j&lt;a; j++) // overwriting the original array
          ar[j] = tmp2[j];
      j++; // incrementing j so that there would be a space between the new array
      z = j; 
      i=0;
  
      while(1) //finding the size of tmp1
      {
          while(tmp1[i] != '\0' &amp;&amp; i&lt;sizeof(tmp1))
              b++;
      }
      //idk pls help
      for( z=0 ; z&lt;MAX; z++) //overwriting the original array
          for(k = 0; k&lt;b; k++)
              ar[z] = tmp1[k];
          //idk pls help
  
      for (i = 0; i &lt; MAX; i++) // outputting the required result
          printf("%c", *(ar+i));
      printf("\n");
  }//eg if input is Hello World   the output should be World Hello//idk pls help
  </code></pre>
  
  <p>The main function calls the function as <code>swap(word1)</code> where <code>word1</code> is <code>char word1[] = {'h','e', etc)</code></p>