diff --git a/sampleMALLOCprogram b/sampleMALLOCprogram new file mode 100644 index 0000000..39324e1 --- /dev/null +++ b/sampleMALLOCprogram @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + char *mem_allocation; + /* memory is allocated dynamically */ + mem_allocation = malloc( 20 * sizeof(char) ); + if( mem_allocation== NULL ) + { + printf("Couldn't able to allocate requested memory\n"); + } + else + { + strcpy( mem_allocation,"fresh2refresh.com"); + } + printf("Dynamically allocated memory content : " \ + "%s\n", mem_allocation ); + free(mem_allocation); +}