471,049 Members | 1,521 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,049 software developers and data experts.

Convert Static Array to Dynamic Array ?

I am using array in my progrm...

is there any tool /tips so that i can convert my program to Dynamic
Array...so that I can Add more Element to Array....

Code is around 4000 line 'C' (not C++) program....

Nov 15 '05 #1
2 5021
On Tue, 12 Jul 2005 23:13:28 -0700, raxitsheth wrote:
I am using array in my progrm...

is there any tool /tips so that i can convert my program to Dynamic
Array...so that I can Add more Element to Array....

Code is around 4000 line 'C' (not C++) program....


Check out the FAQ, in particular question 6.16:

http://www.eskimo.com/~scs/C-faq/q6.16.html

Regarding the final option given there (pointers to arrays) the FAQ says
that "at most one dimension may be specified at run time".

That's no longer true with C99, and my money's on this as the best option
in the case of C99. The advantage it has is that the array's storage
layout is exactly the same as that of a static array with the same
dimension sizes, and there is no need to allocate arrays of pointers. So
you save space and you maintain compatibility with existing code that may
for some reason access the array contents in a way other than normal array
indexing.

Nov 15 '05 #2
On 12 Jul 2005 23:13:28 -0700, ra********@gmail.com wrote in
comp.lang.c:
I am using array in my progrm...

is there any tool /tips so that i can convert my program to Dynamic
Array...so that I can Add more Element to Array....

Code is around 4000 line 'C' (not C++) program....


How is the array defined, and how is it accessed?

It may be as simple as replacing the global array definition with a
global definition of a pointer to that type, and allocating memory for
it early on in main(). Then again, it may not be that simple.

You need to provide more information.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by J Anderson | last post: by
7 posts views Thread by BrianJones | last post: by
115 posts views Thread by Mark Shelor | last post: by
8 posts views Thread by Peter B. Steiger | last post: by
5 posts views Thread by moondaddy | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.