Can someone explain why this works with the pointer:
char * str1; str1 = \"Hello1\"; str1 = \"new string\"; // but not this char str2 [] = \"hello\"; str
Put simply, because an array is not a first-class object in C/C++. The only way to assign to an array is to use str(n)cpy or memcpy.
While an array collapses into a pointer when passed to a function, it is not possible to assign to an array, except at compile-time as initialisation.