954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

clear screen

0
By eagleeye on Jan 30th, 2005 7:37 am

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;
}

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

nico
Newbie Poster
16 posts since Nov 2004
Reputation Points: 10
Solved Threads: 0
 

Than it's mission has been fulfilled

eagleeye
Junior Poster in Training
87 posts since Dec 2004
Reputation Points: 11
Solved Threads: 0
 

hmm. wonder if that works for visual c++

bombe
Newbie Poster
14 posts since Feb 2005
Reputation Points: 10
Solved Threads: 1
 

hmm. wonder if that works for visual c++

bombe
Newbie Poster
14 posts since Feb 2005
Reputation Points: 10
Solved Threads: 1
 

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

bombe
Newbie Poster
14 posts since Feb 2005
Reputation Points: 10
Solved Threads: 1
 

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

eagleeye
Junior Poster in Training
87 posts since Dec 2004
Reputation Points: 11
Solved Threads: 0
 

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
Posting Pro in Training
445 posts since Dec 2004
Reputation Points: 16
Solved Threads: 6
 

try substituting in place of

1o0oBhP
Posting Pro in Training
445 posts since Dec 2004
Reputation Points: 16
Solved Threads: 6
 

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

dave2point0
Newbie Poster
6 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

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)

ShawnCplus
Code Monkey
Team Colleague
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
 

Here are some example how to use windows console api functions

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

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

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

ankit_the_hawk
Light Poster
44 posts since Sep 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You