I'm new to C in linux. Btw, I'm having a problem with function such as pow(x), sqrt(x), etc. For example, i wrote a program like this :
#include
You need to link the math library when you compile. So if your file is called
uaioe.c (and with "#include
I'm new to C in linux. Btw, I'm having a problem with function such as pow(x), sqrt(x), etc. For example, i wrote a program like this :
#include
#include main() { float a, b;
b = pow(a, 3); printf("Result is : %f\n", b); } when i try to compile it using gcc, it keeps telling me an error like this ------> undefined 'pow' in main ....bla bla bla anyone can help?
#include
#include main() { float a, b;
b = pow(a, 3); printf("Result is : %f\n", b); } when i try to compile it using gcc, it keeps telling me an error like this ------> undefined 'pow' in main ....bla bla bla anyone can help?
Works for me. Are you putting "-lm" in your compile line to pull in the math library? --
eatapple core dump
participants (3)
-
Derek Fountain
-
gires
-
Matthew A Tobiasz