What do you suggest to use to replace system("cls")?
There is no universal way of doing this. There's no way of guaranteeing that stdout is even going to the screen, so clearing the output when it could be going to a printer or a file makes little sense. For a simple number guessing game, I'd just leave the console as it is and not worry about clearing it. There are libraries such as ncurses/pdcurses that are designed to allow console output, but I haven't used either one for a long time so I have no idea how portable they are these days.