1. 程式人生 > >C++ new malloc realloc

C++ new malloc realloc

stat int cli () sizeof 存儲空間 div font OS

int* a = new int; ? ? ? ? ?分配了存儲空間,但沒有賦初值

int* a = new int(10) ? ??分配了存儲空間,並賦初值,即*a = 10


int* a = new int[100] ? ? ?分配了存儲空間,但沒有賦初值,a為長度為100的數組的首地址

int* a = new int[100]() ? ?分配了存儲空間,並將數組清零,a為長度為100的數組的首地址



int* a =?(int*)malloc(100*sizeof(int));?

分配了存儲空間,a為長度為100的數組的首地址



int *c = (int*)realloc(a,1000*sizeof(int));

將a的存儲空間拷貝到c,並添加存儲空間;

C++ new malloc realloc