How can I add a timer to my c++ console game

I’m currently working on a console game which you should throw the ball to out of the window to get points. I have a points counter but I want a timer too. Most of the timers on internet are using sleep() function but it stops the game so I can’t use sleep(). Can you give me a method which I can print the time every second and restart it whenever game triggers a new level.

string FirstRenderer()
{
string screen = "";
for (int i = 0; i <= ysize; i++)
{
    // 1st Render Square
    for (int j = 0; j <= xsize; j++)
    {
        if (i == playery && j == playerx) {
            screen += " X";
        }
        else if (i == 0 || i == ysize || j == 0 || j == xsize)
        {
            screen += " o";
        }
        else if (i == engy && j == engx) {
            screen += " O";
        }
        else {
            bool temp = false;
            if (currentLevel == 1)
            {
                int len = sizeof(wallx1) / sizeof(wallx1(0));
                for (int key = 0; key < len; key++)
                {
                    if (j == wallx1(key) && i == wally1(key)) {
                        temp = true;
                        break;
                    }
                }
            }
            if (temp)
            {
                screen += " H";
            }
            else
            {
                screen += "  ";
            }
            
        }
        if (puanUp) {
            while (1)
            {
                srand(time(0));
                engx = rand() % (xsize - 1) + 1;
                engy = rand() % (ysize - 1) + 1;
                puanUp = false;
                if (engx != playerx || engy != playery)
                {
                    break;
                }
            }
        }
        else if (engy == 0 || engy == ysize || engx == 0 || engx == xsize) {
            puan += 1;
            puanUp = true;
        }

    }
    screen += " ";
    // 2nd Render Square
    for (int j = 0; j <= xsize; j++)
    {
        if (i == playery2 && j == playerx2) {
            screen += " X";
        }
        else if (i == 0 || i == ysize || j == 0 || j == xsize)
        {
            screen += " o";
        }
        else if (i == engy2 && j == engx2) {
            screen += " O";
        }
        else {
            screen += "  ";
        }
        if (puanUp) {
            while (1)
            {
                srand(rand());
                engx2 = rand() % (xsize - 1) + 1;
                engy2 = rand() % (ysize - 1) + 1;
                puanUp = false;
                if (engx2 != playerx2 || engy2 != playery2)
                {
                    break;
                }
            }
        }
        else if (engy2 == 0 || engy2 == ysize || engx2 == 0 || engx2 == xsize) {
            puan += 1;
            puanUp = true;
        }
        if (j == xsize) {
            screen += "n";
        }
    }
}

return screen;

}
This is the function renders my game’s screen