DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

C - Clear Screen

09.29.2006
| 19261 views |
  • submit to reddit
        // Simula il comportamente di clear/cls

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
	// Funziona sui terminali compatibili ansi
	
	fprintf(stdout, "\033[2J"); // Cancella lo schermo
	fprintf(stdout, "\033[1;1H"); // Posiziona il cursore sulla linea colonna 1

	return EXIT_SUCCESS;
}