abs 'implicit declaration…' error after including math.h

后端 未结 1 1954
太阳男子
太阳男子 2021-02-19 09:46

I used the abs() function and I added #include at the top of code. But I keep getting this error:

hello.c:20:11: warning         


        
1条回答
  •  再見小時候
    2021-02-19 10:42

    I'm going to quote straight from the docs : "Prototypes for abs, labs and llabs are in stdlib.h"

    As a rule of thumb the mathematical functions that operate on floating point numbers are in math.h, and the ones that operate on integers are in stdlib.h.

    There's a pretty good Wikipedia article on C mathematical functions if you need more information.

    0 讨论(0)
提交回复
热议问题