该函数定义在#include <algorithm>
头文件中
reverse 函数是反转容器中的内容,对字符数组无效
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string s= "hello";
reverse(s.begin(),s.end());
cout<<s<<endl;
return 0;
}
string.h 中的 strrev 函数只对字符数组有效,对 string 类型是无效的
#include<stdio.h>
#include<string.h>
int main()
{
char s[]="hello";
strrev(s);
puts(s);
return 0;
}