data structures - Initialise C Struct in Order to Be Used Globally -


i have following struct:

dict.c

typedef struct dictionary {     int key;     char *word;     char *desc; } dict; 

main.c

#include "dict.c"  dict * d;  function() {     d->key = 1; } 

this throws error: dereferencing pointer incomplete type.

how allow struct read in other functions?

you allocating global pointer, don't. alloc real struct , initialize on declaration:

#include "dict.c"  dict d = {.key = 1, .word = &word_data, .desc = &desc_data}; 

Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -