Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- @author Ramon Caldeira
- */
- #include <windows.h>
- #include <stdio.h>
- #include <conio.h>
- #define TEXT_NORMAL 15
- #define TEXT_REVERSE 240
- #define ENTER 13
- #define UP 72
- #define DOWN 80
- typedef short COLOR;
- void printxy(int x, int y, char* text);
- void setColor(COLOR c);
- void Entrar();
- void Cadastrar();
- void Sair();
- struct OPTION {
- char* description;
- void (*function)();
- };
- OPTION options[3] =
- { {"Entrar", Entrar },
- {"Cadastrar", Cadastrar },
- {"Sair", Sair},
- };
- int main() {
- int selecionado= 0;
- bool done = false;
- char ch;
- do {
- for(int i = 0; i < 3; i++) {
- setColor((selecionado == i) ? TEXT_REVERSE : TEXT_NORMAL);
- printxy(10, 5 + (i * 2), options[i].description);
- }
- ch = getch();
- switch(ch) {
- case ENTER:
- options[selecionado].function();
- done = true;
- break;
- case UP:
- selecionado = (selecionado == 0) ? 0 : selecionado - 1;
- break;
- case DOWN:
- selecionado = (selecionado == 2) ? 2 : selecionado + 1;
- break;
- }
- } while(!done);
- getchar();
- return 0;
- }
- void printxy(int x, int y, char* text) {
- HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
- COORD c = {x - 1, y - 1};
- SetConsoleCursorPosition(hOut, c);
- printf("%s", text);
- }
- void setColor(COLOR c) {
- HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(hOut, c);
- }
- void Entrar() {
- system("cls");
- printf("NOME: \n\n");
- printf("SENHA: ");
- }
- void Cadastrar() {
- int i=0;
- char nome[30];
- char email[30];
- char senha[20];
- system("cls");
- printxy(10, 5, "NOME: ");
- gets(nome);
- printxy(10, 10, "E-MAIL: ");
- gets(email);
- printxy(10, 15, "SENHA: ");
- gets(senha);
- }
- void Sair() {
- exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement