翻转单词顺序
注意ReverseSentence中if条件的顺序,开始把 if(*pBegin == ' ')和 if(*pEnd == ' ' || *pEnd == ' ') 顺序颠倒了,这样会陷入死循环
1 void Reverse(char *pBegin, char *pEnd) 2 { 3 if (pBegin == NULL || pEnd == NULL) 4 return; 5 6 while (pBegin < pEnd) 7 { 8 char temp = *pBegin; 9 *pBegin = *pEnd; 10 *pEnd = temp; 11 pBegin++; 12 pEnd--; 13 } 14 } 15 16 char* ReverseSentence(char *pData) 17 { 18 if(pData == NULL) 19 return NULL; 20 21 char *pBegin = pData; 22 23 char *pEnd = pData; 24 while(*pEnd != '