小编use*_*716的帖子

在char数组中搜索子字符串

据我所知,C++字符串中有一个函数执行子字符串搜索:string1.find(string2).

有没有办法在char中执行相同的操作?以下是我的问题:

    #include <iostream>
    #include <cstring>
    using namespace std;
    int main()
    { 
      char a[]="hello world!";
      char b[]="el";
      //find substring b[] in a[]


    }
Run Code Online (Sandbox Code Playgroud)

假设我需要在字符串中找到子串"el",是否可以这样做?

c++

7
推荐指数
1
解决办法
3万
查看次数

标签 统计

c++ ×1