![]() |
|
#21
|
||||
|
||||
Re: Help analyzing a linked list programHello People. (PLS SEE THIS ONE BEFORE THE ONE ABOVE)
I made an incredible blunder in the post above. I forgot to precede List with the keyword struct. So now i have made some changes to the code above such that I have now declared a variable called mylist which is a structure of type List and declared another pointer variable called mylist_ptr which is of type pointer to List and made it point to the address of mylist Heres the C equivalent: CPP / C++ / C Code:
Code:
And I don't get as to why it still says that mylist_ptr is NOT pointing to a variable of type structure or union. Keen to hear from you guys __________________
Hope to hear from you guys! -------------------------------------------------- Best Regards, Aijaz Baig. |
||||
|
#22
|
|||
|
|||
Re: Help analyzing a linked list programQuote:
From a syntax point of view, mylist is a pointer, not a struct, so the compiler would accept mylist->size. It is telling you that you can't use mylist.size since mylist is not a struct. However... From a functionality point of view, since mylist is an unitialized pointer (its value is not the address of a List struct), dereferencing it would be undefined behavior. (So don't do it.) Why not just declare CPP / C++ / C Code:
Now, the mylist.size refers to the element of the struct that you have declared. However... All of the functions that take a pointer to struct as an argument will require you to give them the address of mylist: CPP / C++ / C Code:
Also note that you can't have a "void" data type. Period. Full Stop. There may be a few other compiler errors to track down and destroy. Regards, Dave |
|
#23
|
|||
|
|||
Re: Help analyzing a linked list programQuote:
CPP / C++ / C Code:
CPP / C++ / C Code:
On the other hand, when you make the typedef for List, then you would not (not) make a declaration like] CPP / C++ / C Code:
If you really like to type "struct" a lot, then you could use it with the struct tag: CPP / C++ / C Code:
Regards, Dave |
Recent GIDBlog
Compress Your Web Site by gidnetwork
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Airport Log program using 3D linked List : problem reading from file | batrsau | C Programming Language | 11 | 29-Feb-2008 07:44 |
| [Include] Doubly-linked List | dsmith | C Programming Language | 6 | 14-Apr-2006 13:12 |
| linked list error message | Krandygrl00 | C++ Forum | 4 | 22-Jun-2005 14:13 |
| search linked list | itsmecathys | C++ Forum | 20 | 18-Apr-2005 01:34 |
Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The