C
void * malloc ( size_t size );
Allocate memory block
Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
void * calloc ( size_t num, size_t size );
Allocate space for array in memory
Allocates a block of memory for an array of num elements, each of them size bytes long, and initializes all its bits to zero.
The effective result is the allocation of an zero-initialized memory block of (num * size) bytes.
c++
new
new操作不会初始化内存
总之 需要需要对内存初始化为0 安全第一
strcpy 后面跟了0
strncpy 后面没跟0
void * malloc ( size_t size );
Allocate memory block
Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
void * calloc ( size_t num, size_t size );
Allocate space for array in memory
Allocates a block of memory for an array of num elements, each of them size bytes long, and initializes all its bits to zero.
The effective result is the allocation of an zero-initialized memory block of (num * size) bytes.
c++
new
new操作不会初始化内存
总之 需要需要对内存初始化为0 安全第一
strcpy 后面跟了0
strncpy 后面没跟0