How to find the index of the first occurrence of substring in a string in C++

1 Answer

0 votes
#include <iostream>
  
int main() {
    std::string s1 = "php c++ python c++";
    std::string s2 = "c++";
    
  	std::cout << s1.find(s2);

    return 0;
}
  
  
  
  
/*
run:
  
4
  
*/

 



answered Dec 9, 2020 by avibootz
...