在 std 中是否有像 find_last_of 这样的函数,但在字符串中没有? [英] Is there a function like find_last_of in std but not in string?
本文介绍了在 std 中是否有像 find_last_of 这样的函数,但在字符串中没有?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道有功能
string::find_last_of
但我想处理一大块 char* 数据.我不想将 char* 分配给字符串.
But I want to process a large chunk of char* data. I don't want to assign the char* to a string.
我知道有一个标准函数
std::find
但它只能在正序列上找到 char* .有没有这样的方法可以逆序查找?如果不在 std 中,有没有办法提升?
But it only can find char* on positive sequence. Is there such a way to find in reverse order? If not in std, is there a way in boost?
推荐答案
在 [first, last) 范围内搜索元素 [s_first, s_last) 的最后一个子序列].
Searches for the last subsequence of elements [s_first, s_last) in the range [first, last).
例如
#include <algorithm>
char *data = ...;
char *data_end = data + size;
char toFind = ...;
char *pfind = &toFind;
char *found = std::find_end(data, data_end, pfind, pfind + 1);
if (found != data_end)
...
这篇关于在 std 中是否有像 find_last_of 这样的函数,但在字符串中没有?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文