Clearing Screens

Hey, guys. Ok, so I'm pretty much a newbie, but I'm going all out trying to be a legit coder eventually.

So, I'm creating a "Polling Program" as a Practice Program in my training, (Polling which Doctor Who Companion is your favorite, since you asked. Heh.) and even though I'll never actually use this program in a legit capacity, I want to clear the screen after each person inputs their choice. Now, I've seen that the
 
system(CLS);

command is bad form, I saw another option,
 
cout << string(50, '\n');


This worked for like the first 10 or so times, then large white boxes, (multiple spaces) started filling up the console in what should be blank areas. What can I do to fix this?

Here's what I have:

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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include <iostream>
#include <string>

using namespace std;
int Choice = 10;
int RoseVotes;
int MarthaVotes;
int DonnaVotes;
int PondVotes;
int ClaraVotes;
char YesNo;

int main()
{
    cout << string(50, '\n');
    while (Choice != 0)
   {
        cout << "                _\n";
        cout << "               /-\\\n";
        cout << "          _____|#|_____\n";
        cout << "         |_____________|\n";
        cout << "        |_______________|\n";
        cout << "      |||_POLICE____BOX_|||\n";
        cout << "       | |¯|¯|¯|||¯|¯|¯| |\n";
        cout << "       | |-|-|-|||-|-|-| |\n";
        cout << "       | |_|_|_|||_|_|_| |\n";
        cout << "       | ||~~~| | |¯¯¯|| |\n";
        cout << "       | ||~~~|!|!| O || |\n";
        cout << "       | ||~~~| |.|___|| |\n";
        cout << "       | ||¯¯¯| | |¯¯¯|| |\n";
        cout << "       | ||   | | |   || |\n";
        cout << "       | ||___| | |___|| |\n";
        cout << "       | ||¯¯¯| | |¯¯¯|| |\n";
        cout << "       | ||   | | |   || |\n";
        cout << "       | ||___| | |___|| |\n";
        cout << "      |¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|\n";
        cout << "       ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\n";
        cout << " -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n\n";

        cout << "Thank you for taking Dallas Wilke's Doctor Who Companion Poll.\n";

        cout << "Please enter the corresponding number to your favorite \"New Who\" companion(s):\n\n";
        cout << '\t' << "1 - Rose Tyler\n";
        cout << '\t' << "2 - Martha Jones\n";
        cout << '\t' << "3 - Donna Noble\n";
        cout << '\t' << "4 - Amy Pond & Rory Williams\n";
        cout << '\t' << "5 - Clara Oswin Oswald\n";
        cout << '\t' << "6 - SEE CURRENT RESULTS\n";
        cout << '\t' << "0 - Exit Program (Data Will Be Lost)\n";
        cout << "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n";
        cout << "Your selection? ";
        cin >> Choice;
        if (Choice == 1)
        {
            cout << "\nYou have chosen Rose Tyler. (Press Enter To Continue)\n\n";
            RoseVotes++;
            cin.get ();
            cin.ignore ();
            cout << string(50, '\n');
            cout << "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n";
        }
        else if (Choice == 2)
        {
            cout << "\nYou have chosen Martha Jones. (Press Enter To Continue)\n\n";
            MarthaVotes++;
            cin.get ();
            cin.ignore ();
            cout << string(50, '\n');
            cout << "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n";
        }
        else if (Choice == 3)
        {
            cout << "\nYou have chosen Donna Noble. (Press Enter To Continue)\n\n";
            DonnaVotes++;
            cin.get ();
            cin.ignore ();
            cout << string(50, '\n');
            cout << "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n";
        }
        else if (Choice == 4)
        {
            cout << "\nYou have chosen Amy Pond & Rory Williams. (Press Enter To Continue)\n\n";
            PondVotes++;
            cin.get ();
            cin.ignore ();
            cout << string(50, '\n');
            cout << "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n";
        }
        else if (Choice == 5)
        {
            cout << "\nYou have chosen Clara Oswin Oswald. (Press Enter To Continue)\n\n";
            ClaraVotes++;
            cin.get ();
            cin.ignore ();
            cout << string(50, '\n');
            cout << "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n";
        }
        else if (Choice == 6)
        {
            cout << "\n ------------------------------------------------\n";
            cout << "|" << '\t' << RoseVotes << '\t' << MarthaVotes<< '\t' << DonnaVotes<< '\t' << PondVotes<< '\t' << ClaraVotes << '\t' << "|\n";
            cout << " ------------------------------------------------\n";
            cout << " " << '\t' << "Rose"  << '\t' << "Martha"  << '\t' << "Donna"  << '\t' << "Ponds"  << '\t' << "Clara\n\n\n";
            cout << "Press Enter to Continue.\n\n";
            cout << string(50, '\n');
            cin.get ();
            cin.ignore ();
        }
        else if (Choice == 0)
        {
            cout << string(50, '\n');
            cout << "\nGoodbye!\n";
        }
        else
        {
            cout << "\nInvalid Selection, please choose again. (Press Enter To Continue)\n\n";
            cin.get ();
            cin.ignore ();
            cout << string(50, '\n');
            cout << "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n";
        }
   }


}


I also read somewhere that it is probably easier to load the ASCII art from a text file than doing it like that, but I don't how to do that yet.
The right format for clearing screens is, system ("cls"); . There you have it. Hope this helps.
That's not really what I was asking, thank you though.

I was told using system commands is not generally good programming practice, so I was wondering if there was another, more acceptable way.
@edwilke86

Here is a ClearScreen function.

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
34
35
// ClearScreen.cpp : main project file.

#include <iostream>
#include <windows.h>

using namespace std;

void ClearScreen();


int main( void )
{
	for (int x=0;x<48;x++)
		cout<<"*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=";
	cout << "  PLEASE WAIT  ";
	Sleep(4000);
    ClearScreen();
    
    return 0;
}

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 );
  }
Topic archived. No new replies allowed.