Verwendung von sin() cos() tan() etc
-
hallo,
wie verwende ich die o.g. Funktionen?Mein kleines Testprogramm lautet
#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { double y, x; y=1; x=cos(y)+3; printf("Cosinus ist %lf", x); system("pause"); }
Als fehlermeldung kommt dann
cos_test.c:(.text+0x1d): undefined reference to `cos' collect2: ld gab 1 als Ende-Status zurück
Was ist da falsch?
-
Beim Compilieren den Schalter
-lm
mit angeben, da die mathematische Bibliothek standardmäßig nicht mitgelinkt wird.