tags:

views:

54

answers:

2

I have #include<math.h>, and I tried to use pow(x, y) and powf(x, y). but it seems neither of them are under c99 standard. and I use the command gcc -std=c99 test.c -o test to compile. what function there exists I can use?

+6  A: 

For histerical reasons, the math library is not bundled in with the rest of the Standard Library. You have to manually add it to the compilation with the -lm option to gcc.

gcc -std=c99 test.c -o test -lm
pmg
+1 for *histerical* reasons. :-)
R..
@R..: I've always wanted to say that ... in a meaningful sentence!
pmg
+4  A: 

Did you link with the math lib?

  gcc -std=c99 test.c -o test -lm
ring0
Ok, I must admit I posted 18 seconds after pmg...
ring0
+1 18 secs means you didn't copy ;)
pmg
@ring0, +1. I appreciate.
antonio081014
+1 for being correct (if slow)
Stephen Canon