1. ホーム
  2. C

関数 'malloc' の暗黙の宣言に対する解決策

2022-02-07 12:33:24

追加する必要があります。

#include 
 This file includes the declaration for the built-in function 
malloc
. If you don't do that, the compiler thinks you want to define your own function named 
malloc
 and it warns you because:
You don't explicitly declare it 
and
There already is a built-in function by that name which has a different signature than the one that was implicitly declared (when a function is declared implicitly, its return and argument types are assumed to be 
int
, which isn't compatible with the built-in 
malloc
, which takes a 
size_t
 and returns a 
void*
).
malloc