pow und math.h

Post Reply
Message
Author
andy
Posts: 150
Joined: 07. Nov 1999 12:51
Location: Kiel
Contact:

pow und math.h

#1 Post by andy »

Moin,

wenn ich die Funktion pow, die normalerweise in math.h ist, aufrufen moechte,
bekomme ich folgende Fehlermeldung:

undefined reference to pow



#include <stdio.h>
#include <math.h>

int main(void)
{
unsigned int zahl, i;
unsigned char dualzahl[17];
printf("Hexzahl eingeben: ");
scanf("%x",&zahl);
fflush(stdin);
for (i=16; i>=1; i--)
{
if ((zahl & (int)pow((double)2,(double)(i-1))) != 0)
{
dualzahl<i>='1';
}
else
{
dualzahl<i>='0';
}
printf("%c",dualzahl<i>);
}
printf("
");
return 0;
}

psychozapp
Posts: 85
Joined: 24. Jan 2000 14:28
Location: Nürnberg

Re: pow und math.h

#2 Post by psychozapp »

Linker problem.
Versuch's mit -lm linken, oder -lmath
ich weiß es jetzt nicht genau.

ciao

Entfernt
Posts: 149
Joined: 22. Jul 1999 12:53

Re: pow und math.h

#3 Post by Entfernt »

Andreas, als OpenSource-Programmierer solltest du dir wirklich eine bessere C-Form besorgen, oder jag deine Programme durch indent...

cu

stephan
Posts: 427
Joined: 05. Aug 1999 12:52
Location: nähe Köln
Contact:

Re: pow und math.h

#4 Post by stephan »

Hi !

Was ist denn an dem Source so schlimm ?! Er ist nur nicht eingerückt. Das ist alles.

Greetz ... Stephan !

andy
Posts: 150
Joined: 07. Nov 1999 12:51
Location: Kiel
Contact:

Re: pow und math.h

#5 Post by andy »

also das mit -lm klappt aber was ist indent... ?
ja ich weiss, es ist nicht eingerueckt, ich werd' mich bessern

imagine
Posts: 74
Joined: 19. Nov 2000 13:57

Re: pow und math.h

#6 Post by imagine »

hi
weiss jemand, wie ich das dem gcc auch unter kdevelop beibringen kann?
(das -lm mein ich)
danke
joerg

stderra

Re: pow und math.h

#7 Post by stderra »

@joerg:
Project->Options-Linker Options->math anklicken

bakunin
Posts: 597
Joined: 16. Aug 1999 6:44
Location: Lorsch (Südhessen)
Contact:

Re: pow und math.h

#8 Post by bakunin »

Hi!

Ich denke, dass in dem Fall das Board an der entfernten Einrückung Schuld war.

Cheers,
Wolfgang

Jochen

Re: pow und math.h

#9 Post by Jochen »

Und wer auf den "hilfe"-Link klicken kann, erfährt auch, dass man Source-Code in [<!--no-->code] ... [<!--no-->/code] einschliessen kann, was die Einrückung erhält und einen fixed font benutzt. Aber man erfährt dort <i>nicht</i>, dass man das [<!--no-->code] ... [<!--no-->/code]-Konstrukt nur einmal pro Posting verwenden sollte, da das Board sonst immer den Inhalt des ersten Blocks ausgibt...

Jochen

Descartes

Re: pow und math.h

#10 Post by Descartes »

und man erfährt dort auch nicht, dass man sowohl \<!--no-->n durch \<!--no-->\<!--no-->n und alle eckigen Klammern durch \<!--no-->[ bzw. \<!--no-->] entwerten sollte weil ansonsten das Board-Script diese auswertet.

Jochen

Re: pow und math.h

#11 Post by Jochen »

Stimmt! Versuch macht kluch... <img src="http://www.pl-forum.de/UltraBoard/Images/Happy.gif" border="0" align="middle">

Post Reply