如何使用 C/C++ 从字符串路径“/user/desktop/abc/post/”中查找子字符串?我想检查该路径中是否存在文件夹“abc”。
路径为字符指针char *ptr = "/user/desktop/abc/post/";
最佳答案
使用std::string
和find
。
std::string str = "/user/desktop/abc/post/";
bool exists = str.find("/abc/") != std::string::npos;
关于c++ - 如何从字符串中查找子字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59207176/