you cannot copy the contents of an array from one array to another as you did above.
int arr[2] is an array of 2 integers arr[0] is the first integer, and arr[1] is the second integer. But. arr is the address (immutable) of the null element of the array.
so when you did newMessage = message; , you did not copy the elements inside the array, not the address in message . which is illegal because the array is a constant pointer to memory. you cannot change it.
With its array of characters. use strcpy or strncpy for copy see man pages for two :)
source share