The difference between the two is that char s[]="Mohan";
is stored in the read-write area of the memory layout of the process.
Whereas char *ptr="Mohan";
the string literal Mohan
is stored in read-only area.
which means you can point the character pointer to any other string literal but cannot edit the string.
#include <stdio.h>
int main(void)
{
char a[] = "Stack"; //Here a is an array of characters
char *p = "overflow"; // p is a pointer to char
a[0] = 's';
printf("%s\n", a); //Output is "stack"
// *p = 'O'; This will cause segmentation fault as you are writing to a read
// only memory
p = a;
*p = 'O';
printf("%s\n", a); //Output is "Otack"
return 0;
}