#include <stdio.h>
int main() {
char src[10] = "Ganesh";
char dst[10];
int ret = strcpy(dst,src);
printf("ret %d src %s dst %s\n",ret,src,dst);
/* strcpy copied only till it encounters '\0' . Usually it will be at the end of script .
But if you put it in between the string , it copies only till that . Same with strncpy , either it stops till
hits number specified or till it hits '\0' .
But memcpy copies entire block , doesnt matter on null string
printf %s prints till it hits '\0' character
*/
//Other example
//char s[5]={'s','a','\0','c','h'};
char s[5]="sa\0ch";
char p[5];
char t[5];
int i;
strcpy(p,s);
memcpy(t,s,5);
for(i=0;i<5;i++)
printf("%c",p[i]);
printf("\n");
for(i=0;i<5;i++)
printf("%c",t[i]);
printf("\n");
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: