Convert Static Array to Dynamic Array ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • raxitsheth@gmail.com

    #1

    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....

  • Netocrat

    #2
    Re: Convert Static Array to Dynamic Array ?

    On Tue, 12 Jul 2005 23:13:28 -0700, raxitsheth wrote:
    [color=blue]
    > 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....[/color]

    Check out the FAQ, in particular question 6.16:



    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.

    Comment

    • Jack Klein

      #3
      Re: Convert Static Array to Dynamic Array ?

      On 12 Jul 2005 23:13:28 -0700, raxitsheth@gmai l.com wrote in
      comp.lang.c:
      [color=blue]
      > 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....[/color]

      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.l earn.c-c++

      Comment

      Working...