您的位置:首页 > 其它

字符串反向输出

2018-04-01 09:30 211 查看
#include<stdio.h>

void AntitoneValue(char* father, char* child)
{
int i,j=strlen(father);
printf("%d\n",j);
for(i=0; i<j; i++)
child[i]=father[j-1-i];//反续
child[i] = '\0';
}

int main()
{
    char s[]="hwelloadfefwfe",s2[100];
    AntitoneValue(s,s2);
    printf("invert is %s",s2);
    return 0;
}

函数功能:将字符串的字符,反过来打印。
这里要注意的是,求字符串长度要用strlen函数,如果用sizeof,求出来的是char型指针所占内存的长度,即4.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  字符串