util.h
Publicado por Hunz 10/12/2004
[ Hits: 7.139 ]
Homepage: http://tnegri.com/
Biblioteca com funcoes uteis..
int setcolor(int cor,int bk); --> Define cores da fonte (azul,laranja..)
int settype(int tipo); --> Define tipo da fonte (negrito,piscando..)
int setxy(int x, int y); --> Move o cursor para a posicao X,Y
int setecho(int echo); --> Liga/deliga o echo
int chartoint(char inteiro); --> Transforma char em int.
int clearscn(); --> Limpa a tela.
**No código vizualisado direto do site tem um exemplo de uso da biblioteca.
#include <stdio.h> // setecho(..); #define OFF 0 #define ON 1 // settype(..); #define RESET 0 #define BOLD 1 #define NEGRITO 1 #define BLINK 5 #define PISCAR 5 // setcolor(.. , ..); #define BLACK 0 #define PRETO 0 #define RED 1 #define VERMELHO 1 #define GREEN 2 #define VERDE 2 #define BROWN 3 #define MARROM 3 #define BLUE 4 #define AZUL 4 #define MAGENTA 5 #define ROSA 5 #define CYAN 6 #define CIANO 6 #define WHITE 7 #define BRANCO 7 #define DEFAULT 9 #define PADRAO 9 int setcolor(int cor,int bk); int settype(int tipo); int setxy(int x, int y); int setecho(int echo); int chartoint(char inteiro); int clearscn(); int setecho(int echo) { if (echo == 1) system("stty echo"); else if (echo == 0) system("stty -echo"); else return 0; return 1; } int chartoint(char inteiro) { int temp; temp = inteiro - '0'; return temp; } int setcolor(int cor, int bk) { cor = cor + 30; bk = bk + 40; printf("{FONTE}33[%d;%dm",cor,bk); return 1; } int settype(int tipo) { printf("{FONTE}33[%dm",tipo); return 1; } int setxy(int x, int y) { printf("{FONTE}33[%d;%dH",y,x); return 1; } int clearscn() { printf("{FONTE}33[2J"); return 1; } /////////////////////////////////////////////////////////////////////////////////////// ---------------------------- EXEMPLO DE USO DA BIBLIOTECA #include "util.h" int main() { int numero; clearscn(); setxy(5,5); setcolor(BRANCO,PRETO); printf("Ola mundo!"); setxy(1,1); setcolor(PRETO,BRANCO); settype(NEGRITO); printf("Ola mundo!!"); setcolor(MARROM,ROSA); setxy(15,3); settype(PISCAR); printf("OLA MUNDO!"); settype(RESET); setxy(3,3); printf("ola mundo.."); setxy(1,12); printf("digite um numero (sem echo): "); setecho(OFF); scanf("%d",&numero); setxy(6,13); printf("voce digitou %d ! :D",numero); setxy(1,14); setcolor(ROSA,PADRAO); printf("digite um numero (com echo): "); setcolor(ROSA,PRETO); setecho(ON); scanf("%d",&numero); setxy(6,15); settype(RESET); printf("voce digitou: %d ! ",numero); setcolor(AZUL,PADRAO); printf(":"); setcolor(VERMELHO,PADRAO); printf("D"); setxy(1,17); numero = chartoint('8'); printf(" -> %d",numero); setxy(1,19); settype(RESET); return 0; }
Contagem de elementos de um array
Teste de desempenho com números primos em C
Nenhum comentário foi encontrado.
Atualizar o macOS no Mac - Opencore Legacy Patcher
Crie alias para as tarefas que possuam longas linhas de comando - bash e zsh
Criando um gateway de internet com o Debian
Configuração básica do Conky para mostrar informações sobre a sua máquina no Desktop
Aprenda a criar músicas com Inteligência Artificial usando Suno AI
Instalando e usando o Dconf Editor, o "regedit" para Linux
Como instalar o navegador TOR no seu Linux
Instalando Zoom Client no Ubuntu 24.04 LTS
Manjaro Substituindo Ubuntu no Desktop (11)
HD SSD inacessível: scsi error badly formed scsi parameters (7)