c++ substr() is broken

If you find that substr is broken you can just use a function. I don’t know why it breaks but it just broke for me.

std::string mysub(std::string word, unsigned int start, unsigned int end){
    std::string savings;
    for (unsigned int c=start; c<end; c++){
        savings+=word[c];
    }
    return savings;
}

It probably is not efficient at all but at least it works all the time.

Leave a Reply

Your email address will not be published. Required fields are marked *