Giovanni's Diary > Subjects > Programming > Gists >

C / clear_screen.c

Clear the terminal screen using ANSI control sequences.

// SPDX-License-Identifier: MIT
// Author: Giovanni Santini
// Github: @San7o

#include <stdio.h>

// Clear screen using ANSI control sequences
// Supported by most Linux / Unix terminals and windows 10+ cmd
void clear_screen(void) {
    printf("\033[2J\033[H");
    fflush(stdout);
}

Travel: Gists, Index