Search code examples
c++textconsoleerasereplit

C++, Clear the screen in Repl.it


I'm using a website, repl.it, to program in C++. I use the site because I often use a computer that can't download the software for c++. I'm trying to make a card game that display the contents of the cards on the console. I need to be able to write and delete information on the screen. The problem is that I don't know how to remove the written text. I tried: std::cout << "\b"; But that was kind of didn't work. Can anyone please help me out?


Solution

  • For clearing the screen use system("clear"). Here is an example.

    #include <iostream>
    #include <cstdlib>
    
    int main()
    {
      std::cout << "Press any key to clear the screen.\n";
      std::cin.ignore();
      system("clear");
    }