How to get substring of N characters from specific index in a string with C++

1 Answer

0 votes
#include <iostream>
  
int main() {
    std::string s = "c++ python java";

    char N = 9;
    std::cout << s.substr(4, N);

    return 0;
}
  
  
  
  
/*
run:
  
python ja
  
*/

 



answered Dec 9, 2020 by avibootz

Related questions

...