I have been experimenting on strings in c. Here in this piece of code.
#include<stdio.h>
int main()
{
char *arr="output";
*arr='s';
printf("%s",arr);
return 0;
}
Where in memory does the string "output" get created and as we have pointer arr(which resides in stack) which is initially pointing to this string,why is it not possible to assign some other char to the pointer? When I tried to run this program,I have seen run time error with signal:11 which is segmentation fault.
I have learnt that in c++, string "output" gets created in read only memory which causes 'deprecated conversion from string constant to ‘char*’ during compilation itself.What is behaviour in c?
Can someone explain me why this causes segmentation fault? And where is this string "output" gets created at the first place.
Thanks.