Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


very easy question


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 da_cobra   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 October 2001 - 06:33 AM

how do I clear my dos-screen in c++ and wich file do I have to include I use MS vc++ thanx in advance

Sponsor:

#2 origil   Members   -  Reputation: 134

Like
Likes
Like

Posted 11 October 2001 - 06:48 AM

include the file
conio.h
and use the functuin
clrscr();

#3 Necrosis   Members   -  Reputation: 150

Like
Likes
Like

Posted 11 October 2001 - 08:16 AM

the C++ way (thats how I think of it anyways) is including
stdlib.h
and using the function:
system("CLS");

Never forget, All your base are belong to us!

#4 Big Sassy   Members   -  Reputation: 310

Like
Likes
Like

Posted 11 October 2001 - 08:28 AM

clrscr() using conio.h wont work with MSVC++. Try SirSmoke''s method.

#5 da_cobra   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 October 2001 - 08:17 PM

just :
system("CLS");

works

didn''t even had to include stdlib.h

thanx for the response


#6 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 12 October 2001 - 11:29 AM

Actually, making system calls like that is a complete hack. To do a clear screen professionally, you need to utilize the windows API. There are functions that were made specifically for this purpose. You need to basically clear the text buffer of the console application. Look up the console functions at MSDN. Its more complicated that a system call such as system("cls");, but, its a better way to do things.

#7 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 16 October 2001 - 04:05 PM

Thanks for the info, helped me too Anyone know (or care to explain) why the conio.h function clrscr() won''t work in MS VC++?

#8 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 16 October 2001 - 05:10 PM

conio is compiler and system specific, it is not part of the c++ standard lib therefore the compiler manufacturers have different conio headers. Because different systems require different ways of accessing the video, there is no standard way to clear a console app. Clearing the screen is not in any way standard across any platform, therefore there are many ways to do it. For a windows console just use the windows API.
  

void clearscreen( HANDLE hConsole )
{
COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */
DWORD dwConSize;
GetConsoleScreenBufferInfo( hConsole, &csbi );
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;

FillConsoleOutputCharacter( hConsole, (TCHAR) '' '',
dwConSize, coordScreen, &cCharsWritten );

GetConsoleScreenBufferInfo( hConsole, &csbi );

FillConsoleOutputAttribute( hConsole, csbi.wAttributes,
dwConSize, coordScreen, &cCharsWritten );

SetConsoleCursorPosition( hConsole, coordScreen );
return;
}
//Clears the screen

void clrscr()
{
clearscreen(GetStdHandle(STD_OUTPUT_HANDLE));
return;
}



maybe this helps, idunno, be sure to include windows.h, etc.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS