Can anybody help me with a code to clear the screen using C++.
I have a program that has to continuously make changes to an array and display the array after each modification.
All I need is a code to clear the screen after each display.
Thank you

Recommended Answers

All 6 Replies

Search the forum, this has been asked and answered before.

Depending on your operating system, use a DOS or Unix call ...

// clear the screen in console mode, the dirty way ...

#include <cstdlib> 

int main(void)
{

  // your code

  system ("cls");
  //system ("clear"); // for Unix
  return(0);
}

Be careful with these old DOS commands, it's easy to whipe out your whole hard-drive!

Does the system ("cls") method work in windows 2k, because in my memory, "cls" is a DOS command and win 2k is not built on DOS.

only one way to find out ?? - Try it!

Does the system ("cls") method work in windows 2k, because in my memory, "cls" is a DOS command and win 2k is not built on DOS.

It does work. The "Command Prompt", as it is called, supports a range of DOS commands. cls, for instance, is one of them.

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.