int main()
{char abc[] = "abc";char def[] = "def";char * const array[] = {"abc", "def"};char * const array2[] = {abc, def};const char * array3[3] = {"abc", "def"};//char * const array3[2]; //error,定义的时候必须初始化,因为数组存储的是常量char mych[] = "hello world";array3[2] = mych;//array3[2][0] = 'z'; //error, 提示不能给常量赋值//array2[0] = mych;//array[0][0] = 'z'; //array[0]指针指向的字符串在文字常量区,不可更改array2[0][0] = 'z'; //array2[0]指针指向的字符串在栈区,可更改cout << array[0] << endl;cout << array2[0] << endl;getchar();return 0;
}
转载于:https://www.cnblogs.com/younes/archive/2010/07/05/1771159.html