<分区>
我有一个字符数组,我想对其进行排序
。问题是,如果我将数组按原样传递给 sort
函数,而不是它实际上转换数组字符,这些字符实际上是 ASCII 等价物中的数字。例如4 变成 52。
std::vector<int> classStudents;
....
char* cend = cAllowedStudents+maxAllowedStudents;
std::sort(cAllowedStudents, cend);
std::set_difference(classStudents.begin(), classStudents.end(),cAllowedStudents, cend,std::back_inserter(diff));
我还尝试通过这个将整个数组转换为单独的 int
数组,(但理想情况下我不想使用另一个数组,只是作为最后的选择):
iAllowedStudents[i]=(int)cAllowedStudents[i];
但它也做同样的事情,所以我如何转换这个 cAllowedStudents
以与 std::set_difference