This is a discussion on Dynamically Allocated Array within the C and C++ forums, part of the Programming Talk category; I have knowledge of array concepts in programming language .But what is dynamically allocated arrays in C programming language. Can ...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
if an array is created at runtime it is known as dynamically created array
we can create array dynamically by using malloc() and calloc() we prefer to create array dynamically becoz there are three problems with static memory allocation consider this int a[10] 1) memory wastage if we store only 5 values the remaining memory of 6 integers is wasted 2)overflow here we can store only 11 integers if we try to store 12th integer it raises overflow becoz how can we store 12 integers if we created array only for 11 integers 3)array size cannot be variable int n=7; int a[n]; // error becoz the value 7 is stored in 'n' at runtime but we are creating arrayat compilation time.at compilation time 'n' is not defined |
![]() |
| Thread Tools | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) | Steve Summit | Tech FAQ | 0 | 06-15-2004 07:00 AM |
| comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) | Steve Summit | Tech FAQ | 0 | 06-01-2004 07:01 AM |
| comp.lang.c FAQ list Table of Contents | Steve Summit | Tech FAQ | 0 | 06-01-2004 07:00 AM |
| comp.lang.c Answers to Frequently Asked Questions (FAQ List) | Steve Summit | Tech FAQ | 0 | 06-01-2004 07:00 AM |
| comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) | Steve Summit | Tech FAQ | 0 | 05-15-2004 07:00 AM |