I'm trying to define a function that will return a pointer to a structure. I think I followed this correctly, (Returning a struct pointer) but my code keeps complaining with this error message when I try to access the pointer's members, "error: dereferencing pointer to incomplete types".
Here's my code
#include <stdio.h>  
#include <string.h>   
#include <assert.h>  
struct lnode  
{  
  char* word;  
  int   line;  
  int   count;  
  struct lnode* nn;     /* nn = next node */  
};
struct lnode* newNode (char* word, int line) 
{
  struct lnode* newn = (struct lnode*) malloc(sizeof (struct lnode));
  if (!newn)
    return NULL;
  strcpy (newn->word, word);
  newn->line  = line;
  newn->count = 1;
  newn->nn    = NULL;
  return newn;
}
int main()
{
  char* p = "hello";
  struct lnode* head = newNode (p, 5);
  //the following lines are causing errors
  assert (!strcmp (head->word, p));     
  assert (head->line  == 5);
  assert (head->count == 1);
  assert (!head->nn);
  return 0;
}
Thanks for the help!
 
     
     
    