Clear screen in C and C++ on UNIX-based system?

前端 未结 10 1589
青春惊慌失措
青春惊慌失措 2020-12-08 08:23

I want to know: how to clean screen on an UNIX-based system? I searched on the Internet, but I\'ve just found how to do it on Windows: system(\"CLS\") I don\'t want exactly

10条回答
  •  借酒劲吻你
    2020-12-08 09:00

    Maybe you can make use of escape codes

    #include 
    
    #define clear() printf("\033[H\033[J")
    
    int main(void)
    {
        clear();
        return 0;
    }
    

    But keep in mind that this method is not compatible with all terminals

提交回复
热议问题