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

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

What can cause "Required Package 'IndyCore' not found" when compiling a Delphi 2010 project? -