I need a timer that does X every second. I made this, however it doesn't print anything until the program is terminated, I find that weird. It prints everything after three seconds if you put three as the counter, and 100 if you chose that.
How do make it print every second and not all at once at termination?
int main()
{
    using namespace std;
    //Number to count down from
    int counter = 10;
    //When changed, a second has passed
    int second = (unsigned)time(NULL);
    //If not equal to each other, counter is printed
    int second_timer = second;
    while (counter > 0) {
        second = (unsigned)time(NULL);
        while (second != second_timer) {
            //Do something
            cout << counter-- << ", ";
            //New value is assigned to match the current second
            second_timer = second;
        }
    }
    cout << "0" << endl;
    return 0;
}