malloc

来自cppreference.com
< c | memory

Defined in header <stdlib.h>
void* malloc( size_t size );
分配size個位元組的未初始化的存儲.
Original:
Allocates size bytes of uninitialized storage.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
如果分配成功,則返回一個指針到最低的(第一個)位元組分配的內存塊,適當的任何對象類型相一致.
Original:
If allocation succeeds, returns a pointer to the lowest (first) byte in the allocated memory block that is suitably aligned for any object type.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
size是零​​,其行為是實現定義的(空指針可能會被退回,可能會被退回,可能無法用於訪問存儲或一些非空指針)
Original:
If size is zero, the behavior is implementation defined (null pointer may be returned, or some non-null pointer may be returned that may not be used to access storage)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[编辑] 參數

size -
要分配的位元組數
Original:
number of bytes to allocate
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[编辑] 返回值

如果發生了錯誤,開始新分配的內存或空指針的指針。指針必須被釋放free().
Original:
pointer to the beginning of newly allocated memory or null pointer if error has occurred. The pointer must be deallocated with free().
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[编辑] 另請參閱