Using the erase Functions with Iterator Arguments - C++ STL

C++ examples for STL:iterator

Description

Using the erase Functions with Iterator Arguments

Demo Code

#include <iostream>
#include <string>

int main(int argc, const char* argv[]) {
    std::string str("This is an sentence");

    str.erase(str.begin() + 9);/*www .  j  av a2  s. c o m*/
    std::cout << str << std::endl;

    str.erase(str.begin() + 5, str.end() - 9);
    std::cout << str << std::endl;

    return 0;
}

Result


Related Tutorials