#include<stdio.h>
#include<string.h>
int my_strlen(char* str)
{
int count = 0;
while(*str !='\0')
{
count++;
str++;
}
return count;
}
void reverse_string(char* str)
{
int left = 0;
int right= my_strlen(str)-1;
while(left<right)
{
char tmp = str[left];
str[left] = str[right];
str[right] = tmp;
left++;
right--;
}
}
int main()
{
char arr[] = "abcdef";
reverse_string(arr);
printf("%s\n",arr);
return 0;
}
标签:fedcba,arr,right,int,char,str,逆序,abcdef,left From: https://blog.51cto.com/u_13668714/5916426