c - Correct way to use memset() on multi dimensional array of type enum -


i have been struggling memset work me.

i have following array type:

typedef enum cell game_board[boardheight][boardwidth]; 

cell enum:

enum cell {    c_empty,    ... } 

but when call memset() initialize values in board c_empty. nothing seems happen:

void init(game_board board) {    memset(board, c_empty, sizeof(board) * boardheight * boardheight); } 

i have tried many different ways of calling memset() think problem in understanding.

you can't set integer value way, memset() sets byte @ time, integer 4 bytes. in particular case posted set 0 since it's 0 works. non-zero values not work correctly.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -