Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Convert Static Array to Dynamic Array ?

Reply
Thread Tools

Convert Static Array to Dynamic Array ?

 
 
raxitsheth@gmail.com
Guest
Posts: n/a
 
      07-13-2005
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....

 
Reply With Quote
 
 
 
 
Netocrat
Guest
Posts: n/a
 
      07-13-2005
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.

 
Reply With Quote
 
 
 
 
Jack Klein
Guest
Posts: n/a
 
      07-14-2005
On 12 Jul 2005 23:13:28 -0700, 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamic arrays (convert vector to array) NeeZee C++ 7 02-04-2006 10:21 PM
How to convert from dynamic polymophism to static polymophism? PengYu.UT@gmail.com C++ 4 11-09-2005 08:28 PM
Can a static array contain a dynamic array of pointers? Peter B. Steiger C Programming 8 04-26-2004 03:07 AM
dynamic URLS convert to static URLS for search engines Steve T. ASP .Net Web Services 7 03-04-2004 03:16 PM
VPN between 2 Cisco routers (1 static, 1 dynamic) with access from stat --> dynamic over ISDN Hans-Peter Walter Cisco 3 01-21-2004 02:12 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57