C++ function that implements a progress bar in console applications