char word[length];
char *rtnPtr = word;
...
return rtnPtr;
This is not good. You are returning a pointer to an automatic (scoped) variable, which will be destroyed when the function returns. The pointer will be left pointing at a destroyed variable, which will almost certainly produce "strange" results (undefined behaviour).
You should be allocating the string with malloc
(e.g. char *rtnPtr = malloc(length)
), then free
ing it later in main
.