I would like to understand the difference between the format of having a pointer to an array of characters declared and initialised to an array of choice example char *s = "Hello";
and having it done the more common way of declaring an array char s[] = "Hello";
I recreated memset and tried using it on the first declaration example which resulted in a bus error. I don't understand why because from what I gather is that in C, the first method of declaring and initialising an array should be the same as the second one in terms of how they are both stored on the stack memory and a pointer being able to interact with the arrays address when the array is passed by reference to my function.
The problem is that I can not alter the first version of the array but I can print it using printf which suggests that altering it should therefore be possible because it IS there somewhere in memory and I have access to its address.
I would just like to have a clear explanation as to what is going on under the hood for both formats. What makes the one achieve the objective yet the other doesn't.
My aim is to just understand as much as I can about C, your help will be appreciated in getting me to soon appreciate the beauty of the language and having a clear picture of how all of its components work together to efficiently solve a problem.
Attached below is my code:
Format that works with my ft_memset.c funct
Format that doesn't work, yet able to print the array