How to get substring between two indexes of a string in C++

1 Answer

0 votes
#include <iostream>
   
int main() {
    std::string s = "c++ python java";
    int start = 2, end = 6;
     
    std::cout << s.substr(start, (end - start));
}
   
   
   
/*
run:
   
+ py
   
*/

 



answered Dec 9, 2020 by avibootz
edited Sep 30, 2024 by avibootz

Related questions

...