answersLogoWhite

0


Best Answer

The obvious answer is that one has a constant size while the other does not. More specifically, a fixed-size array is one where the size is known at compile time and does not change at runtime. By contrast, the size of a variable-sized array may or may not be known at compile time but may change at runtime.

We often refer to a variable-size array as being a dynamic array, however some people (myself included) incorrectly refer to a fixed-size array as being a static array. The misunderstanding largely comes from the fact that we often refer to the heap (or free store) as being dynamic memory because all dynamic variables are allocated there (including variable-size arrays). But the term dynamic array does not refer to the memory, it refers to the dynamic -- as in changeable -- nature of the array itself.

By contrast, a fixed-size array is only deemed static if it is statically allocated, in which case it will be allocated in the program's data segment along with all other static variables, global variables and constants. But a local fixed-size array is allocated on the program's stack and is therefore, by definition, non-static. Moreover, you can allocate a fixed-size array on the heap!

User Avatar

Wiki User

9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between a fixed size array and a variable size array?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is difference between variable capacitor and fixed capacitor?

variable capacitors are those capacitors which can be intially or randomly canged by the user for example radio tunning.whereas fixed capacitors are those whose value is fixed and can't be changed. sohaib


Difference between loop and array?

A loop usually referred to the program flow control with possible repetition of executing the same codes, an array is an abstraction of fixed size container. 2 different concepts.


Is the array size is fixed after it is created?

Generally, a array is fixed in size. With some libraries, however, they are extensible, either by reallocation/copying strategies (C/C++/STL), or by linking/referencing strategies (JAVA).


How can you make a array with the number 16?

If you mean how do you create an array with 16 elements, there are two ways: int a[16]; /* fixed size array of 16 integer elements */ int* b = malloc(16*sizeof(int)); /* variable length array with (initially) 16 integer elements */ Remember that variable length arrays allocated on the heap must be released as soon as they are no longer required: free (b); b=NULL;


What is static array and dynamic array in visual basic?

Generally speaking, a static array is a fixed-length array while a dynamic array is a variable-length array. However, we prefer the terms fixed-length and variable-length because static objects are objects that are allocated in static memory at compile time, which means they have a fixed offset address (the offset remains the same for each execution and will not change at runtime). Dynamic objects, on the other hand, are allocated and destroyed at runtime, which means they have dynamic addresses; each time the object is instantiated we cannot guarantee it resides at the same address. To put it another way, all static arrays must be fixed-length arrays, but not all fixed-length arrays must be static arrays. We can allocate a fixed-length array in static memory (in which case it is also a static array), but we can also allocate a fixed-length array on the call stack or on the heap, in which case we can potentially create more than one instance of that array, each with its own unique address. Consider a recursive function that instantiates a local (non-static) fixed-length array: each instance of that function would instantiate a new instance of that array, each with its own unique address. Similarly with multi-threaded applications: each thread has its own call stack, thus we could potentially have multiple threads invoking the same function and thus instantiating multiple instances of the same array in different call stacks, each with its own unique address. And if we allocate a fixed-length array on the heap, we have no guarantee where that array will be allocated. So whenever we speak of static or dynamic allocations, remember that we are specifically referring to the address (or at least the offset address). Dynamic addresses can change at runtime, static addresses cannot. Although the physical address of a static object can change between executions, its offset address (relative to the start of the static data segment) can never change -- not without recompiling the executable.

Related questions

The difference between fixed and variable inputs?

difference between fixed and variable inputs


What is the difference between fix and variable mortgages?

The difference between fixed and variable mortgages are that in a fixed mortgage, the rate can not change. In a variable mortgage, the rate changes with time.


What is the difference between a fixed resistor and a variable resistor?

its the colour of the fixed and the variable we define it by its power and name


What is the difference between a fixed second mortgage and one with a variable rate?

The difference between a fixed second mortgage and one with a variable rate is that fixed second mortgage has a fixed rate and is commonly thought of as safer than a mortgage with a variable rate.


What is difference between fixed overhead and variable overhead?

The difference between fixed overhead and variable overhead is that fixed overheads are the ones that do not change regardless and variable overheads are the ones that vary depending on the number of units that it produces. An example of fixed overhead is a managers salary.


What determines the difference between a variable and a fixed cost?

The relataionship of cost between the level of production is determine the fixed or variable cost if cost change with production level then it is variable cost otherwise fixed cost.


What is Difference between programmable logic array and programmable array logic?

Using and gate - pla is programmable while pal is fixed


Is an array is a collection of characters that can be fixed or variable?

No. An array is a collection of objects of any type, such as doubles, not just characters. You can even have arrays of arrays, or arrays of structs. In C, the size of an array is fixed, but it is possible to write code that will allow you to manually make it variable in size.


Difference between variable and fixed resistor?

Variable resistors means that a resistor which can change its resistance by control by any person or it self and fixed resistor means that it can not change its value.


What is the difference between variable overheads cost variance andfixed overheads cost variance?

Variable overhead cost variance is that variance which is in variable overheads costs between the standard cost and the actual variable cost WHILE fixed overheads cost variance is variance between standard fixed overhead cost and actual fixed overhead cost.


Difference between semi variable costs and semi fixed costs?

a semi fixed cost moves upward in a step where semi variable cost begining at a given base level


Difference between char and varchar datatypes?

Char is fixed length, while Varchar is variable length.