头文件:
1 #include<stdlib.h> 2 #include<stdio.h> 3 #include<string.h>
1、函数原型:
void inverse(char *str);
方法一:
void inverse(char *str){ char *p1, *p2; char temp; p1 = str; p2 = str + strlen(str) - 1; while(p1 < p2){ temp = *p1; *p1 = *p2; *p2 = temp; p1++; p2--; } }
方法二:
1 void inverse(char *str){ 2 int i, j, temp; 3 4 i = 0; 5 j = strlen(str) - 1; 6 7 while (i < j){ 8 temp = str[i]; 9 str[i] = str[j]; 10 str[j] = temp; 11 i++; 12 --j; 13 } 14 15 }
2、函数原型:
void inverse(char *str,char * str2);
方法:
void inverse(char *str,char * str2){ if(str == NULL) return; if(*str == '