Mail Archives: djgpp/1997/06/12/22:53:07
Michael Johnson (mj AT glasgow DOT prestel DOT co DOT uk) wrote:
: Hello and please take pity on a C newbie,
: I've called the math.h lib and I get a SIGFPE error with what I think is
: a stack dump? Any it will compile but not run.
: Here's what I've got:
: #include <stdio.h>
: #include <math.h>
: main()
: {
: double b;
: printf("the square root of %d is %d\n",b,sqrt(b));
: }
You might like to try giving b a value before using it, and also printing
it as a floating point number rather than an integer. In addition it would
be clearer to write `int main()' and to explicitly return a value before
the end of the function.
If you compile with -Wall and -O, the compiler will point all of these out
to you.
--
George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Merton College, Oxford
- Raw text -