clear screen

eagleeye 0 Tallied Votes 301 Views Share

A simple demostration of how to clear the console screen in at least Dev-C++ 4.9.8.0 (I don't know about the other since I've only tried it on this one, but may and probably works,, with few if at all minor adjustments), what more can I say, other than it's not the best way to do it but may be useful.

#include <iostream>//needs these three lines
#include <stdlib.h>//needs these three lines
using namespace std;//needs these three lines

int main(int argc, char *argv[])
{
  cout << "A simple Demonstartion of system(\"cls\");" << endl;
  system("PAUSE");	
  system("cls");//clears the screen
  cout << "The first two lines are gone" << endl;
  system("PAUSE");	
  return 0;
}
nico 0 Newbie Poster

i modified it a little bit for c and it works , i learned one thing today , thanx

eagleeye 0 Junior Poster in Training

Than it's mission has been fulfilled

bombe 0 Newbie Poster

hmm. wonder if that works for visual c++

bombe 0 Newbie Poster

hmm. wonder if that works for visual c++

bombe 0 Newbie Poster

i just tried it on codewarrior C++ and it didn't work ;/

eagleeye 0 Junior Poster in Training

Sorry about that, but that's the only thing I could find on how to clear the screen, and so far I could get to work only on Dev-C++

1o0oBhP 4 Posting Pro in Training

the code should be ANSI standard code to work on all compilers, and i DONT see any un-ANSI code! it should work on others, i have compiled DevC++ projects on MSVC++ Before without any problems

1o0oBhP 4 Posting Pro in Training

try substituting <cstdlib> in place of <stdlib.h>

dave2point0 0 Newbie Poster

haven't tried this, but it should work on linux if you replace cls with clear

ShawnCplus 456 Code Monkey Team Colleague

system ("cls") and other system commands are handy to get a list of all possible system lines that i know of just go Start>run>cmd>help, it gives a list of all commands that you could use some usefull ones are color ie.
system("color A")
would change the text on the console to bright green (hello matrix)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here are some example how to use windows console api functions

http://www.codexxi.com/MyBlocks.html#atConsoleObj

ankit_the_hawk 0 Light Poster

gr88! not able to being use clrscr() was really pissing me off!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.