Refreshing console screen

Hi All

Just a quick question, im not sure it can be done but i will give it ago.

Basically my program has got quite a few if statements in, and when the user picks an option i would like to take them to a blank screen so that they cant see any of the previous text above. I know i can use \n many times but i don't think this would look ideal.

Any other suggestions?

Thanks
You could use system("CLS") or clrscr()

but clrscr() is a non-standard function, and system.. well.
This may help you..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// ClearScreen.cpp : main project file.

#include "stdafx.h" // Used with MS Visual Express. Remove if using a different compiler
#include <iostream>
#include <windows.h>

using namespace std;

void ClearScreen()
  {
   DWORD n;
  DWORD size;
  COORD coord = {0};
  CONSOLE_SCREEN_BUFFER_INFO csbi;
  HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
  GetConsoleScreenBufferInfo ( h, &csbi );
  size = csbi.dwSize.X * csbi.dwSize.Y;
  FillConsoleOutputCharacter ( h, TEXT ( ' ' ), size, coord, &n );
  GetConsoleScreenBufferInfo ( h, &csbi );
  FillConsoleOutputAttribute ( h, csbi.wAttributes, size, coord, &n );
  SetConsoleCursorPosition ( h, coord );
  }

int main()
{
	for (int x=0;x<48;x++)
		cout<<"*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*="; // Fills screen with a pattern
	cout << "  PLEASE WAIT  "; // adds wait message
	Sleep(4000); // Used as a pause
    ClearScreen(); // Clears screen
    
    return 0;
}
Thanks, but i managed to find one that does the job in 1 line of code

which is

system("cls");

Thanks for your help
Which is exactly what I already said..
sorry, i was ment to mention you above. thanks for your help TheJJJunk
Topic archived. No new replies allowed.