Thread: clear screen function

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    77

    clear screen function

    i know there is a function that is to clear the screen for further operation.

    the header file needed for it is conio.h

    i forgot wat is the function. i tried clrscr() but fail.

    anyone know ?

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Try the FAQ

    I recommend option 6

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    77
    this code like cannot be used in visual c++

    is there any other function that works the same ?

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793

    Unhappy

    Originally posted by monkeymon
    this code like cannot be used in visual c++

    is there any other function that works the same ?
    Option 6 was a joke....
    ....but if only you had kept reading

    Code:
    WINDOWS OPTION: (Credit: Sunlight)
    
    Just call the function clrscr(). Simple as that. 
    
    
    #include <windows.h>
    
    
    
    void clrscr()
    
    {
    
       COORD coordScreen = { 0, 0 };
    
       DWORD cCharsWritten;
    
       CONSOLE_SCREEN_BUFFER_INFO csbi;
    
       DWORD dwConSize;
    
       HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    
    
    
       GetConsoleScreenBufferInfo(hConsole, &csbi);
    
       dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
    
       FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten);
    
       GetConsoleScreenBufferInfo(hConsole, &csbi);
    
       FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
    
       SetConsoleCursorPosition(hConsole, coordScreen);
    
    }

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    77
    im doing a console programing will that work also ? Fordy

    i try already but dun seem to work
    Last edited by monkeymon; 10-05-2002 at 11:05 AM.

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    This compiles fine in VC++

    Code:
    #include <iostream>
    using std::cout;
    using std::endl;
    #include <windows.h>
    
    
    
    void clrscr(){
       COORD coordScreen = { 0, 0 };
       DWORD cCharsWritten;
       CONSOLE_SCREEN_BUFFER_INFO csbi;
       DWORD dwConSize;
       HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
       GetConsoleScreenBufferInfo(hConsole, &csbi);
       dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
       FillConsoleOutputCharacter(hConsole, TEXT(' '), 
    	   dwConSize, coordScreen, &cCharsWritten);
       GetConsoleScreenBufferInfo(hConsole, &csbi);
       FillConsoleOutputAttribute(hConsole, csbi.wAttributes,
    	   dwConSize, coordScreen, &cCharsWritten);
       SetConsoleCursorPosition(hConsole, coordScreen);
    }
    
    int main(){
    
    	const int nTimes = 3;
    	const int nSpeed = 3000;
    
    	for(int i = 0;i < nTimes;i++){
    		cout << "Few seconds to clear screen!!..Hang on!" << endl;
    		Sleep(nSpeed);
    		clrscr();
    		Sleep(nSpeed);
    	}
    
    	cout << "That's all folks!" << endl;
    
    	return 0;
    }

  7. #7
    Registered User
    Join Date
    Apr 2002
    Posts
    77
    thanks for your help ...
    now it can work already ...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Calling a Thread with a Function Pointer.
    By ScrollMaster in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2006, 08:56 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Clear Screen Function?
    By Punkture in forum C Programming
    Replies: 3
    Last Post: 05-05-2003, 09:25 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM