Image

Programs - C Language - Dynamic Memory Allocation

Program:

#include<stdio.h>
#include<conio.h>
void main(){
char *m;
 m=(char*)calloc(20,sizeof(char));
 clrscr();

if(m==NULL)
  printf("Couldn't able to alloacte memory.");
 else {
  strcpy(m,"Hello World!");
  printf("Dynamic memory allocated content %s",m);
 }
 getch();
}