Is there a clear screen command?

This is a discussion on Is there a clear screen command? within the C++ Programming forums, part of the General Programming Boards category; to make my program look neater, i'd find it great to use a command that clears the window of all ...

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

    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
    Spanky devour89's Avatar
    Join Date
    Nov 2002
    Posts
    148

    Angry

    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...

    Code:
    #include <conio.h>
    and then

    Code:
    clrscr();
    call the function and it clears the screen

  3. #3
    Registered User Maiq's Avatar
    Join Date
    Aug 2002
    Posts
    10
    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
    Posts
    533
    OKAY:
    here are the three usefull and commonly overlooked functions everyone should know about!:

    Code:
    int full_screen()
    {
    	keybd_event(VK_MENU,0x38,0,0);
    	keybd_event(VK_RETURN,0x1c,0,0);
    	keybd_event(VK_RETURN,0x1c,KEYEVENTF_KEYUP,0);
    	keybd_event(VK_MENU,0x38,KEYEVENTF_KEYUP,0);
    	return 0;
    }
    int kill_cursor()
    {
    	CONSOLE_CURSOR_INFO cci;
    	cci.dwSize=1;
    	cci.bVisible = FALSE;
    	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cci);
    	return 0;
    }
    
    void clrscrn()
    {
    	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);
    }
    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
    Spanky devour89's Avatar
    Join Date
    Nov 2002
    Posts
    148
    Lynux-Penguin
    >>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
    Posts
    1,078
    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
    Posts
    1,571
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21