Recursive implementation of the Reverse_string (char * string) function.
Flip the original string
is to change
Not print it out.
/* Write a function reverse_string (char * string) (Recursive implementation) implementation: Reverses the characters in the argument string. Requirement: You cannot use the string manipulation function in the C function library. */#include <stdio. H>void reverse_string (char * string) {static char a[100]={0};// static variable record string static char *p=a; Two pointers, different places using static char *q=a;if (*string!= ')//recursive exit {*q=*string; Before recursion, the array a element is initialized to the target string q++;reverse_string (string+1);//recursive call *string=*p; Implement flip p++;}} int main () {char s[]= "Hello World"; reverse_string (s);p rintf ("%s\n", s); return 0;}
"C Language" reverse_string (char * string) (Recursive implementation)