Mail Archives: djgpp/1995/12/08/12:34:18
On 7 Dec 1995, Mark Lewis wrote:
> You need to link the math library to your executable to use math functions.
> Use the -lm flag at the END of your compile command line.
>
> --
> ..--------------------------{ From: Mark Lewis }--------------------------.
> | Computing Services | http://www.city.ac.uk/~sl323/ |
> | City University | PGP public key available by WWW, or by |
> | London, England | fingering sl323 AT finger DOT city DOT ac DOT uk |
> `--------{ M DOT Lewis AT city DOT ac DOT uk (MIME) | nostra AT city DOT ac DOT uk (MIME) }---------'
>
> THutchi141 AT aol DOT com wrote:
> [ stuff ]
> > #include <stdio.h>
> > #include <math.h>
>
> > main()
> > {
> > printf("%d\n",sin(3.0));
> > }
>
You're also using the wrong format character to printf; it should be "%f"
not "%d" ("%d" is for ints, whereas "sin" returns a double)
- Andy
| Andrew Molyneux Internet: molyneua AT cs DOT man DOT ac DOT uk
| University of Manchester Tel : (+44)161-485-3291
| REAL programmers write a=b!=4?b%2?c:d:e without even
| thinking about it :-)
- Raw text -