You should use
the_struct->next->value
but before that, you should be sure that the_struct->next
is valid.
BTW, malloc(3) does fail, and it gives an uninitialized memory zone on success. So read also perror(3) and exit(3), then code:
struct myStruct *the_struct = malloc(sizeof(struct myStruct));
if (!the_struct)
{ perror("malloc myStruct"); exit(EXIT_FAILURE); };
the_struct->value = -1;
the_struct->next = NULL;
(Alternatively, zero every byte of a successful result of malloc
with memset(3), or use calloc
instead of malloc
).
Later on, you might likewise get and initialize a struct myStruct* next_struct
and finally assign the_struct->next = next_struct;
and after that you could e.g. assign the_struct->next->value = 32;
(or, in that particular case, the equivalent next_struct->value = 32;
)
Please compile with all warnings and debug info (gcc -Wall -g
) and learn how to use the debugger (gdb
). On Linux, use also valgrind.