Hey yes, you guessed it was homework. I am trying to print a string in reverse order with pointers. Only words. So hello world is olleh dlrow. What I do in the code below assigns one pointer (pSentence, which is a string array of several words passed from the main function) to a temporary pointer to a space, then increments it back and prints the character from the temporary pointer to the beginning of the word, then do it again. Iโm stuck right now, I donโt know how to mark the beginning of a word and grow only to this. I know that while (pt! = '0') is not a way to do this at all. The tooltip says to save the word in a temporary line (tmpStrg) and use pT to point to it, so maybedo i need to do something using tmpStrg? Any help is greatly appreciated and thank you in advance.
void prtWords(char *pSentence)
{
char tmpStrg[81], *pT=tmpStrg;
int length=0;
while(*pSentence != '\0')
{
while(*pSentence != ' ' && *pSentence != '/0')
{
*pT=*pSentence;
pT++;
pSentence++;
length++;
}
pSentence++;
while(length >= 0);
{
printf("%c", *pT);
pT--;
length--;
}
}
}