为了账号安全,请及时绑定邮箱和手机立即绑定

c语言 字符串数组倒序输出?

c语言 字符串数组倒序输出?

慕雪6442864 2019-02-14 09:11:02
c语言 字符串数组倒序输出
查看完整描述

2 回答

?
慕斯709654

TA贡献1840条经验 获得超5个赞

123456789101112131415161718192021222324/*定义一个函数reverse,该函数的参数为一个字符数组,函数的功能为将输入的字符串倒转后的字符数组。例:reverse("abcd")输出为"dcba"。*/#include<stdio.h>void reverse(char *s){    int n=0;    while (*s!='\0')    {        s++;        n++;    }    s--;    while (n)    {        printf("[%c]",*s--);        n--;    }  } void main()    char a[10] ="abcd";      reverse(a);}[d][c][b][a]Press any key to continue


查看完整回答
反对 回复 2019-03-21
?
慕标琳琳

TA贡献1830条经验 获得超9个赞

123456789101112131415#include <stdio.h>#include <string.h>void reverse(char *str){    strrev(str);//把字符串str的所有字符的顺序颠倒过来(不包括空字符NULL)。     puts(str);    printf("\n");  }int main(){    char str[99];    gets(str);    reverse(str);    return 0;}



查看完整回答
反对 回复 2019-03-21
  • 2 回答
  • 0 关注
  • 1649 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信