Last active
May 5, 2016 15:39
Revisions
-
KaeLL revised this gist
May 5, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ void cls() { COORD coordScreen = { 0, 0 }; DWORD dwConSize, cCharsWritten; CONSOLE_SCREEN_BUFFER_INFO csbi; if ( !GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &csbi )) return; -
KaeLL revised this gist
May 5, 2016 . 2 changed files with 19 additions and 202 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,202 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ #include <Windows.h> void cls() { COORD coordScreen = { 0, 0 }; DWORD dwConSize, cCharsWritten; CONSOLE_SCREEN_BUFFER_INFO csbi; if ( !GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &csbi )) return; dwConSize = csbi.dwSize.X * csbi.dwSize.Y; if ( !FillConsoleOutputCharacter( GetStdHandle( STD_OUTPUT_HANDLE ), ( TCHAR )' ', dwConSize, coordScreen, &cCharsWritten )) return; if ( !GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &csbi )) return; if ( !FillConsoleOutputAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten )) return; SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), coordScreen ); } -
KaeLL created this gist
Jul 21, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,202 @@ #include <iostream> #include <fstream> #include <sstream> #define NOMINMAX #include <Windows.h> using namespace std; bool validateInput( string ); void start(); void editar(); void consultar_todos(); void consultar_atual(); void apagar(); void cls(); int main() { ios_base::sync_with_stdio( false ); start(); } bool validateInput( string num ) { for ( unsigned short i = 0; i < num.size(); ++i ) if ( num[ i ] < 48 || num[ i ] > 57 ) return false; return true; } void start() { char op; do { cout << "Qual das Opcoes Abaixo voce deseja?\n\n" "1 - Editar Numero de Despacho Atual\n\n" "2 - Consultar Documentos de Despacho Anteriores\n\n" "3 - Consultar Proximo Numero de Despacho\n\n" "4 - Apagar Registro de Despacho\n\n" "5 - Sair do Aplicativo\n\n"; cin >> op; cls(); switch ( op ) { case '1': editar(); break; case '2': consultar_todos(); break; case '3': consultar_atual(); break; case '4': apagar(); break; case '5': exit( 0 ); break; default: cout << "\a\nOpcao Invalida!\nDigite novamente\n\n"; } } while ( true ); } void editar() { char a; string num, name, subject; ofstream outfile; outfile.open( "test.txt", ios::app | ios::out ); do { if ( outfile.is_open() && outfile.good() ) { cout << "Numero do Despacho: "; while ( cin >> num && !validateInput( num ) ) cout << "\nEste campo deve ser preenchido com valor numerico, tente novamente.\n\n" "Numero do Despacho: "; } cin.ignore( numeric_limits < streamsize >::max(), '\n' ); cout << "Nome do Enderecado: "; getline( cin, name ); cout << "Assunto do Documento: "; getline( cin, subject ); outfile << num << '\n' << name << '\n' << subject << endl; cout << "\nDeseja inserir mais documentos de despacho? [S/N]\n"; cin >> a; } while ( a != 'n' && a != 'N' ); outfile.close(); } void consultar_todos() { stringstream num; ifstream infile; infile.open( "test.txt" ); if ( infile.is_open() && infile.good() ) { while ( infile.good() ) num << infile.get(); string resultado; num >> resultado; cout << resultado; infile.close(); } } void consultar_atual() { string num; ifstream infile; infile.open( "test.txt" ); if ( infile.is_open() && infile.good() ) { infile >> num; while ( !infile.fail() ) { cout << num << endl; getline( infile, num ); } infile.close(); } } void apagar() { char b; cout << "\nISSO REMOVERA TODOS OS REGISTROS DE DESPACHO, prosseguir? 1 - Sim|2 - Nao\n"; cin >> b; cin.ignore(); switch ( b ) { case '1': remove( "test.txt" ); cout << "\nRegistro excluido com sucesso.\n"; getchar(); break; case '2': cout << "\nOs dados nao foram removidos.\n"; getchar(); break; default: cout << "\a\nOpcao Invalida!\n\n"; getchar(); break; } } void cls() { COORD coordScreen = { 0, 0 }; DWORD cCharsWritten; CONSOLE_SCREEN_BUFFER_INFO csbi; DWORD dwConSize; if ( !GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &csbi ) ) return; dwConSize = csbi.dwSize.X * csbi.dwSize.Y; if ( !FillConsoleOutputCharacter( GetStdHandle( STD_OUTPUT_HANDLE ), ( TCHAR ) ' ', dwConSize, coordScreen, &cCharsWritten ) ) return; if ( !GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &csbi )) return; if ( !FillConsoleOutputAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten ) ) return; SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), coordScreen ); }