Array Subscript Size

why doesnt C allow variable subcripts for array.

Is there a way to do this.


Comments

  • : why doesnt C allow variable subcripts for array.
    :
    : Is there a way to do this.
    :
    :
    :

    I think compilers that are ISO C99 compliant to allow it. That is something relatively new to the standards so not may compilers are yet up-to-speed.
  • when we declare an array....coz it has fixed size.....can i assume that the memory is used from the code segment....




    : : why doesnt C allow variable subcripts for array.
    : :
    : : Is there a way to do this.
    : :
    : :
    : :
    :
    : I think compilers that are ISO C99 compliant to allow it. That is something relatively new to the standards so not may compilers are yet up-to-speed.
    :

  • : when we declare an array....coz it has fixed size.....can i assume that the memory is used from the code segment....
    :
    :

    No you cannot. The memory is not allocated from the code segment. It is either allocated on the stack or the heap
    [code]
    char array[255]; // memory is allocated on the stack

    char* ptr = malloc(255); // memory is allocate from the heap
    [/code]

  • : : when we declare an array....coz it has fixed size.....can i assume that the memory is used from the code segment....
    : :
    : :
    :
    : No you cannot. The memory is not allocated from the code segment. It is either allocated on the stack or the heap
    : [code]
    : char array[255]; // memory is allocated on the stack
    :
    : char* ptr = malloc(255); // memory is allocate from the heap
    : [/code]
    :


    Unless the array is const, because then it is most likely allocated in the code segment.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories