• 0

2d Array to Single


Question

In a C++ program, I have named some controls as such:

IDC_BTN1, IDC_BTN2, IDC_BTN3, IDC_BTN4...

But my board (Tic Tac Toe) that I process is a multidimensional array, so IDC_BTN2 would be [1][2] etc. I am using a loop as like below to input data into these controls, from the multidimensional array, into the buttons.

for ( x=1; x<=setsize; x++ ) {
	for ( int y=1; y<=setsize; y++ ) {
  
	}
}

To manage this I will need to use the two coordinates of the array, to come up with the number that the buttons are (I have em stored in a array). So from the numbers 1 and 2, i need to get the number 2, and the numbers 3 and 2, i need to get the number 12 and so on. How will i do this, any formula anyone knows of?

If such a formula doesn't exist, can anyone suggest an equally practical way to achieve this?

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.