可能重复: pow() isn’t defined
void octal2decimal(char *octal, char *decimal) {
int oct = atoi(octal);
int dec = 0;
int p = 0;
while (oct!=0) {
dec = dec + (oct%10) * pow(8,p++); //since oct is base 8
oct/=10;
}
*decimal = (char)dec;
*/
}对于下面的代码,我得到了这个错误,我不知道为什么我包括math.h,但我仍然得到这个错误
/tmp/cck07bLe.o: In function 'octal2decimal':
data-converter.c:(.text+0x35f): undefined reference to 'pow'
collect2: ld returned 1 exit status
什么意思?我怎么才能修好它呢?
发布于 2012-10-24 16:15:33
数学库不是默认包含的标准C库的一部分。与数学库的链接:
gcc file.c -o file -lmhttps://stackoverflow.com/questions/13053260
复制相似问题