Char C [] = "hello"
Is local data.
C [0] = 'T'; // OK
Char * c = "hello"
Global data, in the static storage area.
* C = 'T'; // false
# Include <stdio. h>/* Example 1 */const char * stra () {/* properly open a static bucket through static */static char STR [] = "hello "; /* If a local data is incorrectly allocated, the returned result is uncertain and insecure after the stack release of the function stops memory, possible recovery at any time */Char STR [] = "hello";/* correct allocation of a Global Array, global area of memory */char * STR = "hello "; return STR;}/* Example 2 */intmain () {static char str1 [] = "hello"; char str2 [] = "hello "; char * str3 = "hello"; char * str4 = "hello"; printf ("str1 = 0x % x \ n", str1 ); printf ("str2 = 0x % x \ n", str2); Printf ("str3 = 0x % x \ n", str3); printf ("str4 = 0x % x \ n", str3);/* symptom summary: 1. The addresses of str1, str3, and str4 remain unchanged. 2. The str3 and str4 addresses are the same. 3. The address of str2 is always variable. Cause: 1. The str1, str3, and str4 addresses are in the static storage space. 2. str3 and str4 are in the same static bucket as strings. 3. str2 is in the stack space. * //}/* [[Email protected] test_class] #. /. out str1 = 0x8049734str2 = 0xbf921e42str3 = 0x8048530str4 = 0x8048530 [[email protected] test_class] #. /. out str1 = 0x8049734str2 = 0xbfd174a2str3 = 0x8048530str4 = 0x8048530 [[email protected] test_class] #. /. out str1 = 0x8049734str2 = 0xbfa84cd2str3 = 0x8048530str4 = 0x8048530 [[email protected] test_class] #. /. out str1 = 0x8049734str2 = 0xbffd00002str3 = 0x8048530str4 = 0x8048530 [[email protected] test_class] #. /. out str1 = 0x8049734str2 = 0xbf954982str3 = 0x8048530str4 = 0x8048530 */