#include <stdio.h> |
#include <alloc.h> |
#include <string.h> |
int main( void ) |
{ |
char *str; |
/* allocate memory for string */ |
str = malloc (10); |
/* copy "Hello" into string */ |
strcpy (str, "Hello" ); |
printf ( "String is %s\n Address is %p\n" , str, str); |
str = realloc (str, 20); |
printf ( "String is %s\n New address is %p\n" , str, str); |
/* free memory */ |
free (str); |
return 0; |
} |