Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int getch();
- void cls();
- int eingabe_Int();
- #include <cstdlib>
- #include <stdio.h>
- #include <iostream>
- #include <termios.h>
- #include <unistd.h>
- #include <windows.h>
- using namespace std;
- int eingabe_Int(){
- double zahl;
- int temp;
- while(true){
- cin >> zahl;
- if(cin.fail()){
- cin.clear();
- cin.ignore();
- cout << "Eingabe ist kein gültiger Int-wert, bitte wiederholen" << endl;
- continue;
- }
- temp = zahl;
- if(temp != zahl){
- cout << "Eingabe ist kein gültiger Int-wert, bitte wiederholen" << endl;
- continue;
- }
- return zahl;
- }
- }
- int getch( ) {
- struct termios oldt,
- newt;
- int ch;
- tcgetattr( STDIN_FILENO, &oldt );
- newt = oldt;
- newt.c_lflag &= ~( ICANON | ECHO );
- tcsetattr( STDIN_FILENO, TCSANOW, &newt );
- ch = getchar();
- tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
- return ch;
- }
- void cls()
- {
- HANDLE hStdOut;
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- DWORD count;
- DWORD cellCount;
- COORD homeCoords = { 0, 0 };
- hStdOut = GetStdHandle( STD_OUTPUT_HANDLE );
- if (hStdOut == INVALID_HANDLE_VALUE) return;
- /* Get the number of cells in the current buffer */
- if (!GetConsoleScreenBufferInfo( hStdOut, &csbi )) return;
- cellCount = csbi.dwSize.X *csbi.dwSize.Y;
- /* Fill the entire buffer with spaces */
- if (!FillConsoleOutputCharacter(
- hStdOut,
- (TCHAR) ' ',
- cellCount,
- homeCoords,
- &count
- )) return;
- /* Fill the entire buffer with the current colors and attributes */
- if (!FillConsoleOutputAttribute(
- hStdOut,
- csbi.wAttributes,
- cellCount,
- homeCoords,
- &count
- )) return;
- /* Move the cursor home */
- SetConsoleCursorPosition( hStdOut, homeCoords );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement