#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
char *ptr;
(ptr = (char *)malloc(0));
if (ptr == NULL)
puts("Got a null pointer");
else
puts("Got a valid pointer");
system("pause");
return 0;
}
想請問為什麼答案會是 got a valid pointer
malloc(0)不就代表ptr沒有被分配到任何的記憶體大小嗎
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.36.201.242
推
02/14 14:46, , 1F
02/14 14:46, 1F
→
02/14 14:47, , 2F
02/14 14:47, 2F