strrev(string)
函数返回给定字符串的反转字符串。下面我们来看一个strrev()
函数的简单例子。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/ymba/6444.html
使用示例文章源自菜鸟学院-https://www.cainiaoxueyuan.com/ymba/6444.html
创建一个源文件:string_strrev.c,其代码如下所示 -文章源自菜鸟学院-https://www.cainiaoxueyuan.com/ymba/6444.html
#include<stdio.h>
void main() {
char str[20];
printf("Enter string: ");
gets(str);//reads string from console
printf("String is: %s \n", str);
printf("\nReverse String is: %s \n", strrev(str));
}
执行上面示例代码,得到以下结果 -文章源自菜鸟学院-https://www.cainiaoxueyuan.com/ymba/6444.html
Enter string: yiibai.com
String is: yiibai.com
Reverse String is: moc.iabiiy
文章源自菜鸟学院-https://www.cainiaoxueyuan.com/ymba/6444.html