Pri*_*ank 2 c++ sorting stl c++11
任何人都知道如何char*使用std::sort()STL 函数对 a进行排序?在 C++ 中
char*
std::sort()
如果我使用 sort(str.begin(),str.end()); 之类的排序。一个错误即将到来 - 'request for member begin and end in str,它是非字符类型'char*'。
我知道如何使用std::sort()in对字符串进行排序#include<algorithm>
#include<algorithm>
Hol*_*Cat 5
如果你有一个指向字符串开头的指针,你可以直接将它std::sort作为第一个参数传递给。
std::sort
然后第二个参数需要是指向字符串结尾的指针。您可以通过向该指针添加字符串长度来获得它。
std::sort(ptr, ptr + std::strlen(ptr));
归档时间:
5 年,3 月 前
查看次数:
122 次
最近记录: