title: How to reset a char array to NULL (empty)
body: <p>I am writing a code to rearrange the words in a string from back to front. I have first managed to arranged the characters from back to front but cannot seem to reset a string to null before swapping the second word in the string a second time and so on. </p>
  
  <p>For example, with the input, "<strong>What the hell is going on here</strong>"</p>
  
  <p>The output turns out to be,  "<strong>here onre going ising hellg thelg Whatg</strong>"</p>
  
  <p>So the last letters of the previous word stay with the "tempWord" variable. How can I fix this? </p>
  
  <pre><code>void revString(char statement[]);
  
  int main (void){
  
  int index;
  char tempWord[LENGTH];
  char statement[LENGTH] = "What the hell is going on here";
  const char s[2] = " ";
  char *word;
  int wordCounter = 0;
  
  
  revString(statement);
  
  printf("%s\n", statement);              //Temp printing
  </code></pre>
  
  <p>(Just so it's clear, the code I'm asking about is below this line)</p>
  
  <pre><code>//////////////////////////////////////////////////////////////////////////////////////
  index = 0;
  word = strtok(statement, s);
  
  while (word != NULL){
      wordCounter++;
  
      for (index = 0; index &lt;= strlen(word); index++){
          tempWord[index] = '\0';
      }
  
      strcpy(tempWord, word);
  
      revString(tempWord);
  
      printf("%s ", tempWord);
  
      word = strtok(NULL, s);
  
  }
  printf("\n");
  printf("%d words", wordCounter);
  
  }
  </code></pre>
  
  <p>Let me know what you think!</p>
  
  <pre><code>void revString(char original[]){
  
  int index;
  char temp[LENGTH];
  int j = 1;
  
  for (index = 0; index &lt; strlen(original); index++, j++){
      temp[(strlen(original) - j)] = original[index];
  }
  
  strcpy(original, temp);
  original[strlen(original)] = '\0';
  
  }
  </code></pre>