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

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -