Кресты / Говнокод #11468 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
void Console :: clear() {
	system("cls");
}

Запостил: Fai Fai, (Updated )

Комментарии (36) RSS

      • oh, shi...

        To accomplish this task for a Win32 console application, use one of the following methods:
        * Use a system function
        #include <stdlib.h>
        void main()
        {
           system("cls");
        }
        * Write a function that will programmatically clear the screen.
        #define PERR(bSuccess, api){if(!(bSuccess)) printf("%s:Error %d from %s \ 
            on line %d\n", __FILE__, GetLastError(), api, __LINE__);}
        
         void cls( HANDLE hConsole )
         {
            COORD coordScreen = { 0, 0 };    /* here's where we'll home the
                                                cursor */ 
            BOOL bSuccess;
            DWORD cCharsWritten;
            CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */ 
            DWORD dwConSize;                 /* number of character cells in
                                                the current buffer */ 
        
            /* get the number of character cells in the current buffer */ 
            bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
            PERR( bSuccess, "GetConsoleScreenBufferInfo" );
            dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
        
            /* fill the entire screen with blanks */ 
            bSuccess = FillConsoleOutputCharacter( hConsole, (TCHAR) ' ',
               dwConSize, coordScreen, &cCharsWritten );
            PERR( bSuccess, "FillConsoleOutputCharacter" );
        
            /* get the current text attribute */ 
            bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
            PERR( bSuccess, "ConsoleScreenBufferInfo" );
        
            /* now set the buffer's attributes accordingly */ 
            bSuccess = FillConsoleOutputAttribute( hConsole, csbi.wAttributes,
               dwConSize, coordScreen, &cCharsWritten );
            PERR( bSuccess, "FillConsoleOutputAttribute" );
        
            /* put the cursor at (0, 0) */ 
            bSuccess = SetConsoleCursorPosition( hConsole, coordScreen );
            PERR( bSuccess, "SetConsoleCursorPosition" );
            return;
         }
        Ответить
        • Т.е. вот это уже не говнокод? 😉
          void cls() {
              printf("\033[2J"); /* Clear the entire screen. */
              printf("\033[0;0f"); /* Move cursor to the top left hand corner */
          }
          Ответить
  • 1) Боян.
    2) Как автор этого ГК ещё не удавился? Посоны, нахуй так жить?


    Пользователь HaskellGovno забанен до 24.07.2012 за нарушение правила 2.2.1 данного сайта.
    Ответить
  • А я юзаю следующее:
    cout<<"\E[H\E[2J"<<endl; //Работает в терминале никсовом и даже в cmd
    Ответить

Добавить комментарий

Переведи на "PHP", guest!

    А не использовать ли нам bbcode?


    8