印象中CString没有这么个函数,不过你一样可以用strrev();来对C++的string进行逆序,因为C++的字符串跟c的是一样的。如果你用mfc的CString,那你可以这样
CString a = "abcdefg";
strrev(a.GetBuffer());//这样a就逆序了。
GetBuffer就是得到char*,把CString跟char*一样处理了
#include
#include
using namespace std;
int main()
{
string str("cvicses");
string s(str.rbegin(),str.rend());
cout << s <
}
//呵呵!既然是c++的string,可以考虑用用string的反向迭代器了
没有哦
但是可以这样用
#include
#include
#include
using namespace std;
void main()
{
string s="abcde";
strrev((char *)s.c_str());
cout<}
调试通过,仍然是用c里面的strrev()函数,呵呵
在C++中string属于容器.你可以定义一个string迭代器,用sort算法实现排序,你去试试。