Skip to content

Latest commit

 

History

History
34 lines (21 loc) · 439 Bytes

File metadata and controls

34 lines (21 loc) · 439 Bytes

1.字符串反转

void char_reverse (char *cha) {

    // 定义头部指针
    char *begin = cha;
    // 定义尾部指针
    char *end = cha + strlen(cha) -1;
    
    
    while (begin < end) {
        
        char temp = *begin;
        *(begin++) = *end;
        *(end--) = temp;
    }
}
使用示例
char ch[] = "Hello World";

char_reverse (ch);

// 有兴趣的可以验证
printf ("%s",ch);