I have no idea if this is explained in a tutorial, but is it possible to make each element of an array part of a struct?
Like:
Code:char myChar [10];
myChar [6] = 'A';
myChar [6].isChanged = TRUE;
Printable View
I have no idea if this is explained in a tutorial, but is it possible to make each element of an array part of a struct?
Like:
Code:char myChar [10];
myChar [6] = 'A';
myChar [6].isChanged = TRUE;
Not sure what you mean, any chance of a better explanation?
It's hard for me to explain it... i'll try my best
In my connect four game, i have a char (defined char board [8] [7]) to keep all the values of the board.
Each space is either equal to O for empty, or X or Q for player pieces.
So when i check if someone has won, i simply check if the current piece equals this player's piece, and then piece above also equals this player's piece, and so on...but i want to make a 2 on 2 version where you can only win if the piece the program is checking is part of your own team.
So...if (board [blah] [blah] == 'X' & board [blah] [blah-1].team == board [blah] [blah].team) Win();
is similar to what i want to do.
oh yes.. each member of an array can be pretty much anything you want, like a struct a class, another array (which is what 2 dimentional arrays are)
try this:
Code:struct Slot
{
int piece;
int team;
};
struct Slot board[8][7];