C programming: Dereferencing pointer to incomplete type error

Posted by confusedKid on Stack Overflow See other posts from Stack Overflow or by confusedKid
Published on 2010-04-05T01:43:10Z Indexed on 2010/04/05 1:53 UTC
Read the original article Hit count: 312

Filed under:
|
|
|

Hi, I am pretty rusty at C, and I'm getting a dereferencing error. Hopefully someone can help me with this? ^_^

I have a struct defined as:

struct {
 char name[32];
 int  size;
 int  start;
 int  popularity;
} stasher_file;

and an array of pointers to those structs:

struct stasher_file *files[TOTAL_STORAGE_SIZE];

In my code, I'm making a pointer to the struct and setting its members, and adding it to the array: ...

 struct stasher_file *newFile;
 strncpy(newFile->name, name, 32);
 newFile->size = size;
 newFile->start = first_free;
 newFile->popularity = 0;
 files[num_files] = newFile;

...

I'm getting a "error: dereferencing pointer to incomplete type" whenever I try to access the members inside newFile. What am I doing wrong? Thanks very much for any help :)

© Stack Overflow or respective owner

Related posts about c

    Related posts about dereference