c++新特性

  1. string里面使用find函数查找子串

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
       
    int main() {
    std::string a="this";
    std::string b="this is b";
    const auto tem= a<=>b;
    auto i=b.find(a);
    if(i!=std::string::npos){
    for (int j = i; j < i+a.size(); ++j) {
    std::cout<<b[j];
    }
    std::cout<<std::endl<<"^"<<i;
    }
    return 0;
    }


c++新特性
https://tsy244.github.io/2023/06/26/cpp/cpp新特性/
Author
August Rosenberg
Posted on
June 26, 2023
Licensed under