int *p = new int; cout <<"p` address :" << p << endl; *p = 123; delete p; // int *p2 = 123; int *p1 = {1, 2, 3, 4, 6}; //以上形式是错误的,计算机只会分配指针占用的内存,但是不会初始化 右边数据的内存 //修正 单独步骤 初始化数据 int *p1; int a[] = {1, 2, 3, 4, 6}; p1 = a; // 将数组名作为首地址赋值给指针,同样指针也可以为数组 int *p3 = new int[10]; p3[0] = 1; p3[1] = 2; p3[2] = 3; cout << *p3 << endl; cout << *(p3+1) << endl; //内存增长对其 4个byte