• + 1 comment

    but why you use recursion, since you are erasing the element from vector, it doesn't make sense to create several stack entries and then removing them with no result ie void. You can erase all zero entries from vector in one go with combination of erase-remove.

    vec.erase(remove(vec.begin(), vec.end(), 0), vec.end());