Answers for "realloc en c"

C
3

c realloc

/*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
*/
Posted by: Guest on February-14-2021
0

realloc in c

#include <stdio.h>
int main () {
   char *ptr;
   ptr = (char *) malloc(10);
   strcpy(ptr, "Programming");
   printf(" %s,  Address = %un", ptr, ptr);

   ptr = (char *) realloc(ptr, 20); //ptr is reallocated with new size
   strcat(ptr, " In 'C'");
   printf(" %s,  Address = %un", ptr, ptr);
   free(ptr);
   return 0;
}
Posted by: Guest on September-03-2021
0

realloc in c

void *realloc(void *ptr, size_t size)
Posted by: Guest on April-20-2021

Code answers related to "C"

Browse Popular Code Answers by Language