I have two structures :
struct bets{
int bets[36];
int last_bet;
}bets
struct board{
int type;
bets *bet;
}board
I created a chunk of shad memory of sizeof(board)
. So, I got a pointer to the Board in shared memory (lest call it ptr).
I did created a new board
and bets
structure,
board *b
, bets * bts
, .... added board->bet = bts
.
Now, I copied the "b" to ptr
memcpy(ptr, bts, sizeof(board))
.
I can access the ptr->type
.
But when I try to access
ptr->bet->last_bet
, I get a segmentation-fault error.
I also tried copying like this:
board *b;
memcpy(ptr, b, sizeof(board));
bets *bts;
memcpy(ptr->bet, bts, sizeof(bets)).
Still getting segmentation-fault error.
How can I copy both struct one inside of the other and still have access to the nested one?