#include<stdio.h> #include<assert.h> void reverse_string(char * start,char * end) { assert(start); assert(end); char tmp; if (start < end) { tmp = *start; *start = *end; *end = tmp; reverse_string(++start, --end); } } int my_strlen(char const *string) { assert(string); int count = 0; while (*string++) count++; return count; } int main() { char src[] = "123456"; int len=my_strlen(src); reverse_string(src,src+len-1); printf(src); system("pause"); return 0; }