Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
char* lw; if((lw=(char *)calloc(2, sizeof(char))==0)) printf("Failed to allocate.\n"); else printf("allocated %p\n", lw);
calloc のマニュアルを読みましたが、迅速で簡単な回答が必要です。なぜ NIL を出力するのですか? それはelseに行くので、lwはおそらくNILになることはできず、「割り当てられた(nil)」を出力しますか?神の手?;)
lwに割り当てているのでcalloc(...) == 0、これはfalseです。あなたはそれを逆にしたい
calloc(...) == 0
false
に置き換え==0))ます)==NULL)。
==0))
)==NULL)