Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <windows.h>
- void clear();
- int main(){
- char string[100];
- printf( "Para limpar:\t:c\n"
- "Para sair:\t:q\n\n");
- do{
- memset(string, '\0', 100); /* Preenche a string com \0 */
- scanf( " %99[^\n]s", string); /* Le a string ate uma nova linha */
- if(string[0] == ':' && string[1] == 'c'){
- clear();
- printf( "Para limpar:\t:c\n"
- "Para sair:\t:q\n\n");
- }
- }while((string[0] == ':' && string[1] == 'q') != 1 );
- return 0;
- }
- void clear() {
- DWORD n; /* Número de caracteres escritos */
- DWORD size; /* número de caracteres visíveis */
- COORD coord = {0, 0}; /* Posição superior esquerda da tela */
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- /* Obter um identificador para o console */
- HANDLE h = GetStdHandle (STD_OUTPUT_HANDLE);
- GetConsoleScreenBufferInfo (h, & csbi);
- /* Encontre o número de caracteres a serem sobrescritos */
- size = csbi.dwSize.X * csbi.dwSize.Y;
- /* Sobrescrever o buffer de tela com espaços em branco */
- FillConsoleOutputCharacter (h, TEXT (' '), size, coord, & n);
- GetConsoleScreenBufferInfo (h, & csbi);
- FillConsoleOutputAttribute (h, csbi.wAttributes, size, coord, & n);
- /* Redefine o cursor para a posição superior esquerda */
- SetConsoleCursorPosition (h, coord);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement