Advertisement

Linked List that looks like an Array

Started by May 05, 2000 09:50 AM
13 comments, last by Yanroy 24 years, 7 months ago
Use a CArray object if your in windows. It acts like a linked list, but had the [] operator overloaded!

PCMCIA - People Can't Memorize Computer Industry Acronyms
ISDN - It Still Does Nothing
APPLE - Arrogance Produces Profit-Losing Entity
SCSI - System Can't See It
DOS - Defunct Operating System
BASIC - Bill's Attempt to Seize Industry Control
IBM - I Blame Microsoft
DEC - Do Expect Cuts
CD-ROM - Consumer Device, Rendered Obsolete in Months
OS/2 - Obsolete Soon, Too.
WWW - World Wide Wait
MACINTOSH - Most Applications Crash; If Not, The Operating System Hangs
Chris F:

can i add a row w/o deleteing everything? (after the initial malloc)





========================
Game project(s):
www.fiend.cjb.net
=======================Game project(s):www.fiend.cjb.net
Advertisement
JonatanHedborg: Yes its quite easy. All you have to do is use realloc().

int *array;int numElements = 10;array = (int *)malloc(sizeof(int)*numElements);numElements = 20;array = (int *)realloc(array,sizeof(int)*numElements);       


Edited by - Chris F on 5/6/00 2:34:23 AM
"I have realised that maths can explain everything. How it can is unimportant, I want to know why." -Me
Thanx!

========================
Game project(s):
www.fiend.cjb.net

Edited by - JonatanHedborg on 5/6/00 3:27:11 AM
=======================Game project(s):www.fiend.cjb.net
Zipster: CArray is an MFC class, which is much more strict statement than just if you''re using windows. Furthermore it''s internal implementation is that of a vector, which gives it different runtime properties than a linked-list.

Buster: Code was lying around. It was from a machine problem in my college data structure class, feel free to use code. That''s why it''s posted.

This topic is closed to new replies.

Advertisement