Thread: ClearScreen

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    195

    ClearScreen

    If most people #include <conio.h> for clrscr() function, how come my conio.h doesn't seem to have it. Does clrscr not appear in VC++ conio?

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Does clrscr not appear in VC++ conio?
    Nope, you have to fake it.
    My best code is written with the delete key.

  4. #4
    Registered User
    Join Date
    Jan 2003
    Posts
    118
    or use system("cls") that I think is in windows.h, it might be in conio.h

    [EDIT]
    Or maybe its in iostream.
    Last edited by Marcos; 05-25-2003 at 07:00 PM.
    Why drink and drive when you can smoke and fly?

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    system is in cstdlib and stdlib.h as it's a standard function in both C and C++.
    My best code is written with the delete key.

  6. #6
    Registered User
    Join Date
    Jan 2002
    Posts
    75
    Or you could just write your own clear screen function

    Code:
    //Basic Functions..
    //basicf.h
    #ifndef _BASICF_H_
    #define _BASICF_H_
    
    #include<windows.h>
    
    void clrscr()
    {
    	HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
    	COORD cScreenStart={0,0};
    	DWORD dwScreenSize;
    	DWORD dwCharsWritten;
    	CONSOLE_SCREEN_BUFFER_INFO cWindowInfo;
    
    	GetConsoleScreenBufferInfo(hOutput,&cWindowInfo);
    
    	dwScreenSize = cWindowInfo.dwSize.X * cWindowInfo.dwSize.Y;
    
    	FillConsoleOutputCharacter(hOutput,TEXT(' '),dwScreenSize,cScreenStart,&dwCharsWritten);
    
    	GetConsoleScreenBufferInfo(hOutput,&cWindowInfo);
    
    	FillConsoleOutputCharacter(hOutput,TEXT(' '),dwScreenSize,cScreenStart,&dwCharsWritten);
    
    	SetConsoleCursorPosition(hOutput,cScreenStart);
    }
    
    #endif // _BASICF_H_
    Just include it as a header file...and well then youve got your very own clear screen function
    MSVC++~

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. clearscreen using borland libraries
    By ryan_germain in forum C++ Programming
    Replies: 2
    Last Post: 08-04-2004, 09:50 AM
  2. clearscreen
    By Jotun in forum C++ Programming
    Replies: 3
    Last Post: 04-18-2004, 03:55 PM
  3. Windows console... clearscreen?
    By gMan in forum Windows Programming
    Replies: 8
    Last Post: 04-11-2003, 01:18 AM
  4. Clearscreen, no, not the usual question!
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2002, 02:05 AM
  5. ClearScreen so bad you cant see anything
    By bluehead in forum C++ Programming
    Replies: 9
    Last Post: 02-26-2002, 01:37 PM