I have to answer if the following code compiles and which are the results:
char *s1 = "A String";
char *s2 = "Other String";
*s1 = *s2;
I didnt really find what happens in the background when you do declarations like that. Is s1 pointing to memory looking like this?:
|A| |S|t|r|i|n|g|\0|
In my understanding *s1 = *s2
is the same like s1[0] = s2[0]
, right?
So why do I get a memory error?
Shouldnt it be?:
|O| |S|t|r|i|n|g|\0|