How to remove the last two characters from a string in C++

1 Answer

0 votes
#include <iostream>

int main() {

    std::string str = "c++ c# javascript python";
    
    str.resize(str.size() - 2);

    std::cout << str;
}




/*
run:

c++ c# javascript pyth

*/

 



answered Feb 17, 2022 by avibootz
...