embeddedlover
Full Member level 5

I have the following two code snippets:
Code 1:
char *a = "India";
char *b = "and";
strncpy(a,b,3);
Code 2:
char a[10] = "India";
char b[10] = "and";
strncpy(a,b,3);
Code snippet 2 works and snippet 1 doesn't work why?
Code 1:
char *a = "India";
char *b = "and";
strncpy(a,b,3);
Code 2:
char a[10] = "India";
char b[10] = "and";
strncpy(a,b,3);
Code snippet 2 works and snippet 1 doesn't work why?