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
Linking Lists work! #110130
01/31/07 01:38
01/31/07 01:38
Joined: Nov 2003
Posts: 108
Oklahoma, USA
FixxeR Offline OP
Member
FixxeR  Offline OP
Member

Joined: Nov 2003
Posts: 108
Oklahoma, USA
Huzzah! Expanding memory abound:

Code:

#include <acknex.c>
#include <litec.h>

typedef struct LList
{
int data;

struct LList *pNext, *pPrev;
} LList;

LList *pStart, *pPtr;

// add a ptr to the linking list
LList *AddPtr(LList *pPrevNode, int data)
{
pPtr = (LList *)malloc(sizeof(LList));

pPtr->data = data;
pPtr->pNext = pPtr->pPrev = NULL;

// does the given node exist
if (pPrevNode == NULL) // no
{
// do we have a starting node
if (pStart == NULL) //no
pStart = pPtr;

} else {
pPrevNode->pNext = pPtr;
pPtr->pPrev = pPrevNode;
}

return pPtr;
}

// find an item in the linking list
LList *FindPtr(LList *pStartNode, int finddata)
{
LList *pCurrentNode;

pCurrentNode = pStartNode;

while (pCurrentNode != NULL)
{
if (pCurrentNode->data == finddata)
return pCurrentNode;

pCurrentNode = pCurrentNode->pNext;
}

return NULL;
}
int main()
{
LList *pFoundNode;

AddPtr(NULL, 10);
AddPtr(pStart, 20);
AddPtr(pStart->pNext, 30);

if((pFoundNode = FindPtr(pStart, 20)) == NULL)
MessageBox(NULL, "Node not found!", "Linking List Test", MB_OK);
else
MessageBox(NULL, "Item Found!", "Linking List Test", MB_OK);

}



I'm a happy programmer now, .

FixxeR


John Dies at the End - One of the best fictional stories online. Join the fight for Internet Freedom
Re: Linking Lists work! [Re: FixxeR] #110131
01/31/07 05:17
01/31/07 05:17
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
nice stuff!
ive set this as favourite thread coz i think its a great example of some clever programming you couldn't do with c-script. i understand it mostly, though i couldn't program that myself without having some references.

again, good stuff!

julz


Formerly known as JulzMighty.
I made KarBOOM!
Re: Linking Lists work! [Re: JibbSmart] #110132
02/03/07 06:33
02/03/07 06:33
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Don't forget to 'free' the memory when you are done.

This might be evidence that 'standard' C code works with Lite C without modification, but I don't think that, when taken alone, is really 'impressive'.

Many references for C data structures are freely available.

Re: Linking Lists work! [Re: testDummy] #110133
02/03/07 18:19
02/03/07 18:19
Joined: Nov 2003
Posts: 108
Oklahoma, USA
FixxeR Offline OP
Member
FixxeR  Offline OP
Member

Joined: Nov 2003
Posts: 108
Oklahoma, USA
Yeah, at that point I was just looking for proof of concept with lite-C.

FixxeR


John Dies at the End - One of the best fictional stories online. Join the fight for Internet Freedom

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