字符串反向输出
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.
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.
相关文章推荐
- C/C++:递归使用:使用递归反向写文件(例子)以及字符串翻转输出
- 数据结构之对任意长的字符串反向输出
- leetcode-Reverse Words in a String 反向输出字符串
- C/C++ | 18-3 递归反向输出字符串
- 用递归函数实现字符串反向输出
- 字符串按词反向输出
- 字符串反向输出
- 字符串反向输出
- 字符串反向输出
- 字符串反向输出(控制换行符)
- Reverse String反向输出字符串
- [面试] 递归 反向输出链表 ,定义一个求字符串长度的函数, 反向输出字符串. 不能再函数内部定义变量.
- 递归反向输出字符串
- 对于输出的字符串进行反向输出(不包括汉字)
- [面试] 递归 反向输出链表 ,定义一个求字符串长度的函数, 反向输出字符串. 不能再函数内部定义变量.
- 递归输入字符串反向输出
- 编写代码将字符串反向排列输出
- 递归反向输出字符串
- 如何实现字符串的反向输出
- java中如何反向输出字符串