From 4468cf7dce4e4ed0d5f71b7e1e71d2e1132773f5 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Fri, 19 Oct 2018 01:56:28 +0530 Subject: [PATCH] Create sampleMALLOCprogram --- sampleMALLOCprogram | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 sampleMALLOCprogram 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); +}