#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> #include <stdlib.h> void reverse_str(char *str) { char tmp; int len = strlen(str); if (*str != ‘\0‘) { tmp = *str; *str = str[len - 1]; str[len - 1] = ‘\0‘; reverse_str(str + 1); str[len - 1] = tmp; } } int main() { char str[] = "abcdef"; reverse_str(str); printf("%s", str); system("pause"); return 0; }
原文地址:http://10740184.blog.51cto.com/10730184/1711907