• [摘录]console 清屏


    #include <windows.h>
    
    void cls( HANDLE hConsole )
    {
       COORD coordScreen = { 0, 0 };    // home for the cursor 
       DWORD cCharsWritten;
       CONSOLE_SCREEN_BUFFER_INFO csbi; 
       DWORD dwConSize;
    
    // Get the number of character cells in the current buffer. 
    
       if( !GetConsoleScreenBufferInfo( hConsole, &csbi ))
       {
          return;
       }
    
       dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
    
       // Fill the entire screen with blanks.
    
       if( !FillConsoleOutputCharacter( hConsole,        // Handle to console screen buffer 
                                        (TCHAR) ' ',     // Character to write to the buffer
                                        dwConSize,       // Number of cells to write 
                                        coordScreen,     // Coordinates of first cell 
                                        &cCharsWritten ))// Receive number of characters written
       {
          return;
       }
    
       // Get the current text attribute.
    
       if( !GetConsoleScreenBufferInfo( hConsole, &csbi ))
       {
          return;
       }
    
       // Set the buffer's attributes accordingly.
    
       if( !FillConsoleOutputAttribute( hConsole,         // Handle to console screen buffer 
                                        csbi.wAttributes, // Character attributes to use
                                        dwConSize,        // Number of cells to set attribute 
                                        coordScreen,      // Coordinates of first cell 
                                        &cCharsWritten )) // Receive number of characters written
       {
          return;
       }
    
       // Put the cursor at its home coordinates.
    
       SetConsoleCursorPosition( hConsole, coordScreen );
    }
    
    int main( void )
    {
        HANDLE hStdout;
    
        hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
    
        cls(hStdout);
        
        return 0;
    }
    
    -------------------------------
    void ClearScreen ();
    
    HANDLE  hConsoleOut;        /* Handle to the console */
    CONSOLE_SCREEN_BUFFER_INFO csbiInfo;   /* Console information */
    
    int main(int argc, char* argv[])
    {
        hConsoleOut = GetStdHandle( STD_OUTPUT_HANDLE );
        GetConsoleScreenBufferInfo( hConsoleOut, &csbiInfo );
        ClearScreen();
        return 0;
    }
    
    void ClearScreen ()
    {
        DWORD    dummy;
        COORD    Home = { 0, 0 };
        FillConsoleOutputCharacter (hConsoleOut, ' ', csbiInfo.dwSize.X * csbiIn
    fo.dwSize.Y, Home, &dummy );
        SetConsoleCursorPosition (hConsoleOut, Home);
    }
    
  • 相关阅读:
    Tomcat部署web项目,虚拟目录,上下文(Context),WEB-INF,web.xml,servlet,404
    Android异常:唤醒锁未授权。(Caused by: java.lang.SecurityException: Neither user 10044 nor current process has android.permission.WAKE_LOCK.)
    .hiverc
    Hive安装
    搭建Kafka开发环境
    java实现Kafka的消费者示例
    java实现Kafka生产者示例
    Kafka集群部署
    kafka介绍
    Pig UDF 用户自定义函数
  • 原文地址:https://www.cnblogs.com/mathzzz/p/2845044.html
Copyright © 2020-2023  润新知