The following program is supposed to convert the string into "pig latin." "This is a test string" is supposed to become "hisTay siay aay esttay tringsay." Basically move the first letter to the end and then add "ay." For some reason my program is producing a segmentation fault. Specifically the strtok right after the while condition is what's causing it. I'm not sure why. Is it because I'm passing NULL to the strtok?

Code:
#include <stdio.h>
#include <string.h>

int main()
{
  int i;
  char *tokenPtr;
  char string[] = "This is a test string";

  tokenPtr = strtok( string, " " );

  while ( *tokenPtr != NULL ) {
    tokenPtr = strtok( NULL, " " );
    for ( i = 1; (*(tokenPtr + i) != '\0') && (*(tokenPtr + i) != NULL); ++i ) {
      printf( "%c", *(tokenPtr + i) );

      //    printf( "%cay ", *tokenPtr );
    }
    printf( "%cay ", *tokenPtr ); 
  }

  printf( "\n" );

  return 0;
}