How to remove first N characters from a string in C++

1 Answer

0 votes
#include <iostream>

int main() {
    std::string str = "c++ programming";
    
    int N = 6;
     
    if (!str.empty()) {
        str.erase(0, N);
    }
    
    std::cout << str;
}




/*
run:


ogramming

*/

 



answered Jun 13, 2022 by avibootz
...