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

1 answer 127 views
1 answer 101 views
1 answer 113 views
1 answer 110 views
1 answer 108 views
...