How to remove the first and the last character from a string in C++

1 Answer

0 votes
#include <iostream>
#include <string>

int main() {
    std::string s = "c++ programming";
    
    s = s.substr(1, s.size() - 2);
    
    std::cout << s << std::endl;
}


/*
run:

++ programmin

*/

 



answered Sep 7, 2024 by avibootz

Related questions

...