answersLogoWhite

0

Does array save memory

Updated: 11/4/2022
User Avatar

Wiki User

13y ago

Best Answer

No, it use memory, just like any other variable.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Does array save memory
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the need of array variables?

congugative memory allocation ,is use to array


Why fixed size array is not efficient?

It's not exactly true. Array with fixes size are efficient, but do not work well when you have to resize your array. This actually is the answer for your question. Fixed size arrays are not efficient if you have to change the size. Also you cannot destroy them and release memory used to save the array (for that you have to use operator new).


How will you find the location of an element of an array?

Basically, &array[i]; That is, the memory location for an array object with index i. Or, you can do: (array + i);


Passing an array name to a pointer assigns the first memory location of the array to the pointer variable?

Yes, passing an array name to a pointer assigns the first memory location of the array to the pointer variable. An array name is the same as a pointer to the first location of the array, with the exception that an array name is a r-value, while a pointer is an l-value.


What is the term given to the memory allocation that takes place during run time rendering the resizing of an Array?

A reallocation. Note that whenever we reallocate an array, we increase the size of the current allocation if there is sufficient free memory beyond the current allocation or we allocate entirely new memory if there isn't. But when we reduce the size of an array, we simply release the redundant memory at the end of the array; we never allocate new memory. However, because the amount of memory being allocated has to either increase or reduce in size, both are termed a reallocation.

Related questions

What is the need of array?

congugative memory allocation ,is use to array


What is the need of array variables?

congugative memory allocation ,is use to array


Why fixed size array is not efficient?

It's not exactly true. Array with fixes size are efficient, but do not work well when you have to resize your array. This actually is the answer for your question. Fixed size arrays are not efficient if you have to change the size. Also you cannot destroy them and release memory used to save the array (for that you have to use operator new).


How will you find the location of an element of an array?

Basically, &array[i]; That is, the memory location for an array object with index i. Or, you can do: (array + i);


What are array of string pointers?

An array of pointers to string would contain, per array position, a number dictating which memory address holds the string data. For example, position [0] in an array would contain a memory address. This memory address can be de-referenced to obtain the actual information held within that memory address.


How to display the content of memory address stored in an element of an array?

void *array[2]; printf ("array[%d]=%p\n", i, array[i]);


Passing an array name to a pointer assigns the first memory location of the array to the pointer variable?

Yes, passing an array name to a pointer assigns the first memory location of the array to the pointer variable. An array name is the same as a pointer to the first location of the array, with the exception that an array name is a r-value, while a pointer is an l-value.


What an array?

An array is an aggregate of data elements of the same type. Arrays are allocated in contiguous memory. An element of an array can be another array type, also known as a multi-dimensional array.


What is the term given to the memory allocation that takes place during run time rendering the resizing of an Array?

A reallocation. Note that whenever we reallocate an array, we increase the size of the current allocation if there is sufficient free memory beyond the current allocation or we allocate entirely new memory if there isn't. But when we reduce the size of an array, we simply release the redundant memory at the end of the array; we never allocate new memory. However, because the amount of memory being allocated has to either increase or reduce in size, both are termed a reallocation.


In what are various cells of memory allocated consecutively?

Contiguous memory address are allocated to an array or vector.


When is memory allocated when declaring an array in C plus plus?

It depends how the array is declared (fixed size or variable size) and where it is declared (global scope or local scope). If the array is declared in global scope (outside a function) and is fixed size, it will be allocated in static memory. If it is variable size, the pointer is stored in static memory while the array itself is allocated on the heap. The pointer in static memory points to the start address of the array in heap memory. If the array is declared in local scope (inside a function) and is fixed size, it will be allocated on the stack in whichever thread the function was called. If it is variable size, the local pointer is stored on the stack while the array is allocated on the heap. The pointer will fall from scope when the function returns so the array must not be allowed to outlive the function in which the pointer is declared. If the array must outlive the function that allocates the array, the pointer must be declared at a higher scope in the call stack and must be passed by reference to or returned by value from the function that allocates the array. If you provide your own memory manager, however, an array may be allocated wherever the memory manager's memory pool is allocated, be it in static memory, the stack or the heap. A memory manager essentially allocates an array of bytes which you can then utilise as you see fit (the array of bytes will be allocated as per the previous description for arrays in general).


What is Arrays of Pointers?

An array of pointers is a contiguous block of memory that contains pointers to other memory locations. They essentially allow non-contiguous memory locations to be treated as if they were an actual array.