Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

realloc in c

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

   ptr = (char *) realloc(ptr, 20); //ptr is reallocated with new size
   strcat(ptr, " In 'C'");
   printf(" %s,  Address = %u
", ptr, ptr);
   free(ptr);
   return 0;
} 
Source by www.guru99.com #
 
PREVIOUS NEXT
Tagged: #realloc
ADD COMMENT
Topic
Name
2+3 =