I have a structure:
struct mystruct { int* pointer; }; structure mystruct* struct_inst;
Now I want to change the value pointed to by struct_inst->pointer. How can I do that?
struct_inst->pointer
EDIT
I didn't write it, but pointer already points to an area of memory allocated with malloc.
pointer
malloc
As with any pointer. To change the address it points to:
struct_inst->pointer = &var;
To change the value at the address to which it points:
*(struct_inst->pointer) = var;
2.1m questions
2.1m answers
60 comments
57.0k users