您的位置:首页 > 其它

自己动手实现字符串倒叙

2013-07-23 16:09 363 查看
#include <stdio.h>
//将字符串s倒叙
void strrev(char *s)
{
char *p=s,t;
if(*p)
while(p[1])
p++;
while(s<p)
{
t=*s;
*s++=*p;
*p--=t;
}

}
void main ()
{
char s[]="abcdef";
strrev(s);
puts(s);
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: