Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Can't find the clrscr() program

Can't find the clrscr() program

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialhelpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fredrik N
    wrote on last edited by
    #1

    Some time ago I remember seeing an example of how to do a clrscr() in VC, without using system("cls") way. But now I can't find the example/program anywhere... Are there someone out there who can help me find this example again?

    C A 2 Replies Last reply
    0
    • F Fredrik N

      Some time ago I remember seeing an example of how to do a clrscr() in VC, without using system("cls") way. But now I can't find the example/program anywhere... Are there someone out there who can help me find this example again?

      C Offline
      C Offline
      Carlos Antollini
      wrote on last edited by
      #2

      the function is _clearscreen(_GCLEARSCREEN); Is declared in graph.h Regards There are two ways to write error-free programs; only the third one works. Carlos Antollini. Sonork ID 100.10529 cantollini

      1 Reply Last reply
      0
      • F Fredrik N

        Some time ago I remember seeing an example of how to do a clrscr() in VC, without using system("cls") way. But now I can't find the example/program anywhere... Are there someone out there who can help me find this example again?

        A Offline
        A Offline
        Atul Dharne
        wrote on last edited by
        #3

        /* Standard error macro for reporting API errors */
        #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;
        

        }

        IMO never seen any clrscr() type function in VC. The above will help you to clear the console. Atul Sonork ID : 100.13714 netdiva

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups