c语言中求一个字符串的逆序

来源:互联网 发布:vs code php 开发 编辑:程序博客网 时间:2024/05/17 02:45
#include <stdio.h>#include <string.h>#define MAX_SIZE 1024                        //定义数组长度,避免幻数void get_restr(char  *str, int len)           //字符串的逆序函数{    char temp;    int i;    for(i = 0; i < len / 2; i++)    {        temp = *(str + i);        *(str + i) = *(str + len - i - 1);        *(src + len - 1 - i) = temp;    }    return 0;}void main(){    char str[MAX_SIZE];    printf("Please input str"):    scanf(" %s",str);    get_restr(str,strlen(str));       printf("re_str = %s\n",str);    return 0;}

0 0