#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void reverse_str(char *left, char *right)
{
while (left < right)
{
char tmp = *left;
*left = *right;
*right = tmp;
left++;
right--;
}
}
int main()
{
char a[] = "abcdef";
int len = strlen(a);
char *left = a;//指向字符a
char *right = a + len - 1;//指向字符f
reverse_str(left,right);
printf("%s\n",a);
system("pause");
return 0;
}
将一个字符串的内容,逆序存储
最新推荐文章于 2023-12-14 11:27:37 发布