123456789101112
#include <stdio.h> #include <stdlib.h> int main() { char *pDestn,*pSource="I Love You Daddy"; pDestn=(char *)malloc(strlen(pSource)); strcpy(pDestn,pSource); //*(pDestn+16)='\0'; printf("%s",pDestn); free(pDestn); //printf("hello"); }
pDestn=(char *)malloc(strlen(pSource) + 1);//terminating zero