Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Linked lists as containers #349522
12/08/10 16:55
12/08/10 16:55
Joined: Feb 2006
Posts: 52
C
carlpa Offline OP
Junior Member
carlpa  Offline OP
Junior Member
C

Joined: Feb 2006
Posts: 52
To all the wonderful, kind, and understanding programers out there,

Thank you in advance for your help. I am trying to create a linked list set of "methods" which can be in a "linked_list.c" file and included in many different programs. My idea is create a list of elements. Each element has a void pointer (void* ptr;) as a member. This pointer should be able to point to anything, structure, variable, STRING*, etc, which is why it is declared void in the element definition.

What is the best way to assign this pointer to the required item?


Researcher & clinician. A6, A7, & A8
First computer a Commodore Pet
Re: Linked lists as containers [Re: carlpa] #349523
12/08/10 17:04
12/08/10 17:04
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
"What is the best way to assign this pointer to the required item?"
By casting it to a void pointer. Srsly, all pointers are equal in their bitdepth and endianess (at least throughout one application run), no matter of their name. Its just to make it more convenient for the user, but in fact you could do everything with a typeless void pointer as well.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Linked lists as containers [Re: WretchedSid] #349536
12/08/10 18:15
12/08/10 18:15
Joined: Feb 2006
Posts: 52
C
carlpa Offline OP
Junior Member
carlpa  Offline OP
Junior Member
C

Joined: Feb 2006
Posts: 52
Thank you.

I assume that your reply is to be used thusly:

Element.ptr = (void*) pointer-to-item

not (void) even though the variable pointer-to-item is already a pointer and Element.ptr is defined as void*.

Using Element.ptr = pointer-to-item does not seem to work.


Researcher & clinician. A6, A7, & A8
First computer a Commodore Pet

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1