Can someone please explain to me why strcpy() is necessary to assign strings to character arrays, such as in the following code snippet.
int main(void) {
char s[4];
s = "abc"; //Fails
strcpy(s, "abc"); //Succeeds
return 0;
}
What is the reason that s = "abc" fails? And why is strcpy() the only way to assign strings to char arrays after they have been declared? It seems strange to me that you have to use a function to carry out a basic assignment.