Mastermind---How to show numbers in certain areas?

When the user uses the program the numbers need to be stored into a temp array to show in certain spots of the board. The code is at the bottom. Any help will be appreciated.

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
#include<iostream>
#include<Windows.h>
#include<time.h>

using namespace std;

int get_digit();
void goto_xy(int col, int row);
void hide_ans(int line);
void display_question_marks(int r);  // r --> rows, t --- number of tries



int main()
{
	srand(time(0));


	int answer[4], guess[4] = {0}, i, rows = 17, tries = 1,Number;

	for (i = 1; i <= 4; i++)		// Generate random numbers between 1 and 6
	{
		Number = rand()% 9 + 1;
		cout << Number << endl;
	}



	
	hide_ans(rows);							//	system("COLOR 02");

	display_question_marks(rows);
		
	cout << endl << endl;
		
	system("pause");
	
	return 0;
}



void goto_xy(int c, int r)	// Function moves cursor to correct column and row (screen)
{ 

    COORD coord;
    coord.X = c;
    coord.Y = r;
				//Use a built-in function that will use the "coord" coordinates and place the cursor
				// at the requird location on the screen.

     SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); 

     return;
}
	
int get_digit()				// generates random digits 1 - 9
{
	int num;

	num = rand() % 8 + 1;

	return(num);
}


void hide_ans(int line)			// display titkw, hides the answer
{								// prints row numnbers  line --> rows
	int col, i, ro;

	col = 20;
	ro = 3;

	goto_xy(25, 0);
	cout << "Master Mind";

	
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 3); //replace the number with a number for the color you want
	for (i = 0; i < 4; i++)
	{
		goto_xy(col, ro);
		cout << (char)219;
		col = col + 5;
	}

	for(i = 1; i <= 7; i++)			// prints number of attempts
	{
		goto_xy(15, line);
		cout << i;
		line = line - 2;
	}
	
	return;
}
void display_question_marks(int r) 
{
	int col, i, ro;
		
	col = 15;
	ro = 17;
	
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 4); //replace the 0 with a number for the color you want
	col = col + 5;
	for(i = 0; i < 4; i++)		// prints questions marks on current attempt
	{
		goto_xy(col, r);
		cout << "?";
		col = col + 5;
	}

	return;
}
Topic archived. No new replies allowed.