So I have a stack of
struct board_struct {
int rows;
int cols;
char board[MAX_R][MAX_C]
};
typedef struct stack_S {
Board boards[80];
int size;
} Stack;
typedef struct board_struct Board;
typedef struct board_struct *BoardPtr;
I have
Board
*BoardPtr
Stack stack
When I push I want the current board to be put into the stack and then the program will change it and push the new board into the stack
lets say this pop function
Board pop() {
stack->size--;
return stack->boards[stack->size];
}
Here is my push
void push(BoardPtr b) {
Board n = *b;
stack->boards[stack->size] = n;
stack->size++;
}
The thing is that the board put into the stack has to be separated or copied from the BoardPtr and put into the Stack so that I can make changes to the BoardPtr later on. Then when I pop it I set the BoardPtr to the last board from the stack.
How can I copy the Board without changing the pointer so I can save it into a stack?