C语言填空:利用指针形成逆序字符串函数

#include <stdio.h>1//逆序输出任意字符串 
void severse_string(char2】str)
{
    int len = strlen(str);
    char* left = str;
    char* right = str + len - 1;
    while (left < right)
    {
        char tmp = *left;
        *left = *right;
        *right = tmp;
        left++;
        right--;
    }
}
main()
{
    char zf[100];
    int a,b;
    【3】;
    severse_string(【4】);
    【5】;
    getchar();
}

 

#include <stdio.h>
#include <string.h>
//逆序输出任意字符串 
void severse_string(char* str)
{
    int len = strlen(str);
    char* left = str;
    char* right = str + len - 1;
    while (left < right)
    {
        char tmp = *left;
        *left = *right;
        *right = tmp;
        left++;
        right--;
    }
}
main()
{
    char zf[100];
    int a,b;
    gets(zf);
    severse_string(zf);
    puts(zf);
    getchar();
}

 

posted @ 2023-02-18 11:19  myrj  阅读(41)  评论(0编辑  收藏  举报