Nice to know you occasionally ask someone other than me for help :p
Here's my working routine:
Code:
void printLatinWord(char *myWord) {
char tempChar='\0';
int wordLen=0;
char tempWord[MAX_SIZE] = { '\0' };
char *myWordPtr = tempWord;
// set tempChar to the first letter of the word, cycle each letter down by one, and
// append the letter to the end of the word.
tempChar = myWord[0];
wordLen = strlen(myWord);
int i;
for (i = 0; i < (wordLen - 1); i++) /* we go to wordLen - 1 so we can overwrite
the last letter with the first letter, and
then append 'a' 'y' '\0' */
myWordPtr[ i] = myWord[i+1];
myWordPtr[ i] = tempChar; // append the first letter
myWordPtr[++i] = '\0'; // strcat is expecting an ASCIIZ string
strcat(myWordPtr,"ay"); // should add the \0
printf("%s",myWordPtr);
}
So you can see strlen() is used to return the correct index* of the null terminator; You overwrite the null terminator with the first letter from the word, and then put the null terminator in index+1 (or "i" in the case of my code). Using strcat to add the "ay" takes care of the null terminator automatically.
*because we used a for loop that terminated at strlen(myWord) - 1, the for loop's counter ends up equal to strlen(myWord), and there's no need for a second call to strlen(), although you can add it in if you find it makes your code easier to understand.
EDIT: Bloody vBcode read my index as an italics tag. Ignore the spaces