Char *s1= "Hello"; Point to Constant area
Char s2[]= "Hello"; Memory space pointing to an array
Char *s1 's S1 is a pointer to a piece of memory area, the size of the memory area it points to can change at any time, and when the pointer to a constant string, its contents can not be modified, otherwise at run time will be error.
Char s2[] s2 is an array corresponding to an area of memory, whose address and capacity will not change in the lifetime, only the contents of the array can be changed.
char s2[] = "Hello"; "
s1=s2; //OK
s2=s1//Error
also when using strcpy strcpy (S2,S1) is possible, and because S1 is T-pointing character constants cannot be modified, strcpy (S1,S2) is not able to pass.
when Char*s1=s2, the compiler automatically converts to CHAR*S1=&S2, which is equivalent to two.
The two pointers are assigned a different value
Char*s1="Hello"; Char s2[]="World"; Char **s3=&S1; // Char **s4=s2; ERRORchar *s4=S2; Char **s5=&s4;cout<<*s3<<""<<*s5;
The output "Hello world", char[] will be assigned in two steps.
Returns the difference between char* and char[] in a function:
Returns char* points to a constant area that can continue to exist after the function has ended.
char[], stack function end recycle, return garbled, to return can be declared inside the function with static char[]
Char* and char[]