#include<stdio. h>
int main(void){
char a[]="abcde";
char *p=a;
p++;
p++;
p[2]='z';
printf("%s\n",p );
return 0;
}
output :
cdz
ok than ,
#include<stdio. h>
int main(void){
char *p="abcde";
p[2]='z';
printf("%s\n",p );
return 0;
}
output:
Segmentation fault
In both cases P is of the type char * than in one case the z can
change and the othe csae z cnt change Why ?? Please explain ..
int main(void){
char a[]="abcde";
char *p=a;
p++;
p++;
p[2]='z';
printf("%s\n",p );
return 0;
}
output :
cdz
ok than ,
#include<stdio. h>
int main(void){
char *p="abcde";
p[2]='z';
printf("%s\n",p );
return 0;
}
output:
Segmentation fault
In both cases P is of the type char * than in one case the z can
change and the othe csae z cnt change Why ?? Please explain ..
Comment