c realloc
int ptr_new = *realloc(void *ptr, size_t size);
Where 'ptr_new' is the new pointer you want to point to the required Dynamic
memory, 'ptr' is the already existing pointer to a dynamic memory and 'size'
is the new size of dynamic memory that you want to allocate.
Working:
Realloc creates/allocates a new memory in heap with specified size and copies
all the contents from the previous memory pointer to by the pointer 'ptr'.
It the deallocates the memory in heap pointed to by the old pointer i.e, 'ptr'.
Note: pointer 'ptr' should also point to a memory in heap./*prototype of realloc*/
void *realloc(void *ptr, size_t newsize);
/*use*/
dyn_array = realloc(dyn_array, (dyn_array_size + 1) * sizeof(int));
/*
adds one more space to dyn_array
you need stdlib.h for this
*/
Also in C:
- Title
- Write a C program to add negative values among N values using 2D array and pointer
- Category
- C
- Title
- how to remove \n from a string c
- Category
- C
- Title
- avl tree c implementation
- Category
- C
- Title
- puts without newline c
- Category
- C
- Title
- c file
- Category
- C
- Title
- windowns 10 allow ping
- Category
- C
- Title
- lelcetric fied
- Category
- C
- Title
- WARNING: QA Issue: rdepends on
- Category
- C
- Title
- functions in c
- Category
- C
- Title
- cannot update windows 10
- Category
- C
- Title
- how can i show ant text by onclick
- Category
- C
- Title
- c program average of 3 numbers
- Category
- C
- Title
- python web crawler
- Category
- C
- Title
- find the largest number in else if javascript
- Category
- C
- Title
- material ui icons
- Category
- C
- Title
- npm fs zip
- Category
- C
- Title
- C bitwise integer absolute value
- Category
- C
- Title
- c allocate array
- Category
- C
- Title
- c va_list example
- Category
- C
- Title
- cannot get / react router dom
- Category
- C
- Title
- vbnet create and write on file
- Category
- C
- Title
- how to change the mapping from jkil to wasd in vim
- Category
- C
- Title
- how to put quotes inside string c
- Category
- C
- Title
- strcmp in c
- Category
- C