Advertisement

REALLY nasty array problem - Need urgent help

Started by May 21, 2000 02:54 AM
11 comments, last by TheGecko 24 years, 7 months ago
You need 2 arrays to start off with.

BYTE *Array1;
BTTE *Array2;

At first, create both arrays with the same # of elements.
Array1 = new BYTE[1];
Array2 = new BYTE[2];

As you read in values, use one array as temporary storage.

Array1[LoopIndex] = Value;
Array2[LoopIndex] = Value;

delete Array1;
Array1 = new BYTE[NewSize]
Copy Array2 to Array1
delete Array2;
Array2 = new BYTE[NewSize]
Copy Array1 to Array2

As your program progresses, the arrays will grow as needed
Corrections for above:

Was:
Array2 = new BYTE[2];

Should Be:
Array2 = new BYTE[1];

Was:
Array1 = new BYTE[NewSize]

Should Be:
Array1 = new BYTE[NewSize];

Was:
Array2 = new BYTE[NewSize]

Should Be:
Array2 = new BYTE[NewSize];

I accidentally posted anonymously before and couldn't edit it.

Edited by - DaWanderer on May 22, 2000 5:02:49 PM
Advertisement
Thanx for the other ideas.

Zipster,the reason why I can''t use a dynamic array is becasue I''ll need to know the final size of my lookup table before hand in order to create my array.If you read my post you''ll know that that''s exactly what my problem is.I cannot possibly tell what the final size is.

I am well aware that I''ll need to sort my lookup table.That wasn''t a problem.Now that I got my whole lookup table issue solved I''m working on a sorting algo.The vectors thing did the job really well and all is going good.Thanx to all thos who helped!



-----------------
www.DigitalSV.com

This topic is closed to new replies.

Advertisement