error: invalid application of ‘sizeof’ to incomplete type ‘struct ’

list.c:47:39: error: invalid application of ‘sizeof’ to incomplete type ‘struct Litsnode’

So, I was trying to run a program based on linked list and this is what I got.
This is a very silly problem. I am mentioning it here just to help those who got frustrated like me :-\


Let me show you the line where this error occurred :

46  struct Listnode * newnode;
47  newnode = (struct Listnode *) malloc(sizeof(struct Litsnode));

Now, View it properly. Check the name(spelling) of the structure mentioned to sizeof : "struct Litsnode". Though the defined name of the structure was : "struct Listnode"

That's it. 
This happens all the time that we may type something wrong. The important thing is to identify it. :-)

Feel free to give any suggestions :)

Comments

  1. Was sitting all evening trying to understand what is wrong with my program and all it was I mistyped "Connection"- forgot second n.
    Than you for paying my attention Gene or else I think I would never ever found it. ;)
    -Ed

    ReplyDelete
  2. i have also done the same mistake and it makes me laugh that i was getting frustrated over a silly mistake thank you for sharing the useful info.

    ReplyDelete

Post a Comment

Popular posts from this blog

error: stray '\' in program

ssh: Could not resolve hostname git: No address associated with hostname