c++ - Pointers and enum in C -


i'm trying rewrite c++ code c , got problems comparising enum pointers. please take look.

enum:

enum state{title,play,lost} 

my function looks that:

void changestate(int *state, int newstate) { state = newstate;  if (state == title) { /* */ } else if (state == play) { /* something2 */ } else if (state == lost) { /* something3 */ }  } 

and when try calling function by:

changestate(&state, title) 

etc. doesn't work correctly. when put in code:

if (state == title) { /* instructions */  } 

what mistake? advance time.

you need dereference pointer (use *state) read value points to

this means code should change to

void changestate(int *state, int newstate) {     *state = newstate;      if (*state == title)     {         /* */     }     else if (*state == play)     {         /* something2 */     }     else if (*state == lost)     {         /* something3 */     }  } 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -