At 2007-01-09T09:21:48+1300, David Merrick wrote: > Another small problem with C. My C compiler dosen't sqrt(expression). > It gives "undefined reference to sqrt" error however it accept > sqrt(9), Any suggestions?
You need to link against the math library, e.g.
% cc -o foo foo.c -lm
The reason it works when you pass a constant value is that the compiler is
optimizing the call to sqrt() away as a constant load of the value of
sqrt(9.0).
Cheers,
-mjg
--
Matthew Gregan |/
/| [EMAIL PROTECTED]
