Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


clrscr() in VC++?

This topic is 6130 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! the function clrscr() doesnt work in VC++, but it does work in C++ Builder. What the function does is, it clears the screen of a console application, removing all text. Is there a similiar function in VC++ aswell? Maybe clrscr() actually does exist in VC++ but in that case how do you implement it in a program? What headerfile do you have to include? thanks

Share this post

Link to post
Share on other sites
On an ANSI console (that is, with ansi.sys loaded up in the system), print out the following string "0x1B[2J".

Share this post

Link to post
Share on other sites
The system function passes command to the command interpreter, which executes the string as an operating-system command. system refers to the COMSPEC and PATH environment variables that locate the command-interpreter file (the file named CMD.EXE in Windows NT). If command is NULL, the function simply checks to see whether the command interpreter exists.


/* SYSTEM.C: This program uses
* system to TYPE its source file.

#include "process.h"

void main( void )
system( "type system.c" );

That should help =)


Edited by - Axehandler on December 14, 2001 2:30:32 PM

Share this post

Link to post
Share on other sites
Process.h is not a standard header file. The system function is in stdlib.h. Also, you can clear a Win32 Console using the Win32 console API (I hope I do this correctly ):
bool ClearScreen(void) {
HANDLE hconsole = GetStdHandle(STD_OUTPUT_HANDLE);

if(!GetConsoleScreenBufferInfo (hconsole, &csbi))
return false;

COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
DWORD dwConSize = csbi.dwSize.X * csbi.dwSize.Y;

return (FillConsoleOutputCharacter (hconsole, ' ', dwConSize, coordScreen, &cCharsWritten) &&
FillConsoleOutputAttribute(hconsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten) &&
SetConsoleCursorPosition(hconsole, coordScreen));

[Edited for line length]
[Resist Windows XP's Invasive Production Activation Technology!]

Edited by - Null and Void on December 14, 2001 5:29:47 PM

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!