Convert Static Array to Dynamic Array ?

Discussion in 'C Programming' started by raxitsheth@gmail.com, Jul 13, 2005.

  1. Guest

    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....
    , Jul 13, 2005
    #1
    1. Advertising

  2. Netocrat Guest

    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.
    Netocrat, Jul 13, 2005
    #2
    1. Advertising

  3. Jack Klein Guest

    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/~ajo/docs/FAQ-acllc.html
    Jack Klein, Jul 14, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter B. Steiger

    Can a static array contain a dynamic array of pointers?

    Peter B. Steiger, Apr 19, 2004, in forum: C Programming
    Replies:
    8
    Views:
    2,085
    Dave Thompson
    Apr 26, 2004
  2. Replies:
    4
    Views:
    337
    mlimber
    Nov 9, 2005
  3. NeeZee
    Replies:
    7
    Views:
    4,682
    Aaron Graham
    Feb 4, 2006
  4. dynamic, static array -> sizeof()

    , May 18, 2008, in forum: C Programming
    Replies:
    5
    Views:
    1,462
    Antoninus Twink
    May 19, 2008
  5. Steve T.

    dynamic URLS convert to static URLS for search engines

    Steve T., Mar 1, 2004, in forum: ASP .Net Web Services
    Replies:
    7
    Views:
    276
    Steve T.
    Mar 4, 2004
Loading...

Share This Page