目标:仅使用指针表示法,编写一个函数,将字符列表中的所有值向左(朝向开头)旋转一个元素。
#include <stdio.h>
void rotateLeft( char word[] );
int main (void)
{
//  Local Definitions
    char word[20] = "applications";
//  Statements
    printf( "Before rotation: %s\n", word );
    rotateLeft( word );
    printf( " After rotation: %s\n", word );
    return 0;
}
/*  =================================================================== */
/*  Rotate left
    PRE: word[]
    POST: word rotated left
*/
void rotateLeft( char word[] )
{
    char hold;
    char *pW;
    pW = word;
    hold = *pW;
    while (*pW != '\0')
    {
        printf("%c ", *pW);
        *pW = *(pW + 1);
        *pW++;
    }
    *(pW - 1) = hold;
    *pW = '\0';
    return;
}
我的导师告诉我使用 *(pW + 1) 是一种非常丑陋的风格。我想知道是否有另一种方法可以在不使用我当前使用的样式的情况下解决此解决方案。