Thread: Is there a clear screen command?

  1. #1
    Registered User Maiq's Avatar
    Join Date
    Aug 2002

    Is there a clear screen command?

    to make my program look neater, i'd find it great to use a command that clears the window of all data so i can print out a new section of results to the user. something like 'clearscreen' or 'clear' ? any help would be great. thanks

  2. #2


    Before asking questions that have been asked ten billion times check the FAQ and if that doesn't work do a search... but i'll tell you since i'm sick and don't have anything else to do...

    #include <conio.h>
    and then

    call the function and it clears the screen

  3. #3
    Registered User Maiq's Avatar
    Join Date
    Aug 2002
    thanks. sorry, haven't been here in a while and forgot about the FAQ section. i'll remember that from now on. :P

  4. #4
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    here are the three usefull and commonly overlooked functions everyone should know about!:

    int full_screen()
    	return 0;
    int kill_cursor()
    	cci.bVisible = FALSE;
    	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cci);
    	return 0;
    void clrscrn()
    	COORD coordScreen={ 0, 0};
    	DWORD cCharsWritten;
    	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);
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

  5. #5
    >>here are the three usefull and commonly overlooked functions everyone should know about!:

    you make things too hard! ppl don't expect you to explain all the detail to them and i mean look he is a noob to c++ probally (no offence) and here you are explaining the pro stuff. Hold up explaining ??? i'm sorry you haven't even explained them so pls keep it simple

  6. #6
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    His example is windows-only. If you are looking for portability, avoid it, if not, the windows console functions are very well documented on msdn. Don't be too quick to back down. The functions will make your life easier and let you do things like double buffering that you wouldn't be able to do by standard.

  7. #7
    Registered User
    Join Date
    Apr 2002
    Also be careful with that conio.h header. I mean if you're just doing little stuff its fine but realize it is NOT ANSI standard.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting a clear screen...
    By Finchie_88 in forum C++ Programming
    Replies: 13
    Last Post: 09-03-2004, 05:38 PM
  2. Clear Screen Again!!!
    By trang in forum C Programming
    Replies: 3
    Last Post: 12-13-2003, 07:36 AM
  3. Yet another clear screen thread :D
    By kermit in forum Linux Programming
    Replies: 2
    Last Post: 11-20-2003, 04:14 AM
  4. How to clear the screen?
    By Zopyrus in forum C++ Programming
    Replies: 8
    Last Post: 11-07-2003, 09:20 PM
  5. clear screen code, can't get it to work
    By Unregistered in forum C++ Programming
    Replies: 11
    Last Post: 01-25-2002, 12:38 PM
Website Security Test