圆的问题 [英] problem with round
问题描述
全部,
i我试图使用圆形()函数,我通过google
在math.h中声明(
http://www.gnu.org/software/ libc / man ... unctions.html)。
此函数不起作用,我得到一个未引用的符号错误。当包含math.h时,
函数rint()有效。
是否在所有math.h文件中找不到round()?如果是这样的话可能是一个
替代方案。我在一台运行sparc-sun-solaris的机器上运行
系统,gcc版本为2.95.2。
谢谢
all,
i am trying to use the function round() which I found through google
to be declared in math.h (
http://www.gnu.org/software/libc/man...unctions.html).
this function does not work and i get an unreferenced symbol error. the
function rint() works when math.h is included.
is round() not found in all math.h files? if so what might be an
alternative. i work on a machine that runs a sparc-sun-solaris operating
system with gcc version 2.95.2.
thanks
推荐答案
m< ma ** @ mschumacher.com>写道:
m <ma**@mschumacher.com> writes:
我正在尝试使用函数round(),我通过google发现它在math.h中声明(
http://www.gnu.org/software/libc/男人... unctions.html)。这个
功能不起作用,我得到一个未引用的符号错误。
函数rint()在包含math.h时有效。
i am trying to use the function round() which I found through
google to be declared in math.h (
http://www.gnu.org/software/libc/man...unctions.html). this
function does not work and i get an unreferenced symbol error. the
function rint() works when math.h is included.
这是在C FAQ中。
14.3:我正在尝试做一些简单的触发,我正在#including< math.h>,
但是我一直得到undefined:sin编译错误。
答:确保你实际上是在连接数学库。对于
实例,在Unix下,在编译/链接时,通常需要使用-lm选项,命令行的* end * * * *。另请参阅
问题13.25,13.26和14.2。
-
int main(void){char p [] =" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz. \
\ n",* q =" kl BIcNBFr.NKEzjwCIxNJC" ;; int i = sizeof p / 2; char * strchr(); int putchar(\
); while(* q){i + = strchr(p,* q ++) - p; if(i> =(int)sizeof p)i- = sizeof p-1; putchar(p [i] \
);}返回0;}
This is in the C FAQ.
14.3: I''m trying to do some simple trig, and I am #including <math.h>,
but I keep getting "undefined: sin" compilation errors.
A: Make sure you''re actually linking with the math library. For
instance, under Unix, you usually need to use the -lm option, at
the *end* of the command line, when compiling/linking. See also
questions 13.25, 13.26, and 14.2.
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Ben Pfaff写道:
Ben Pfaff wrote:
m< ma ** @ mschumacher.com>写道:
m <ma**@mschumacher.com> writes:
我正在尝试使用函数round(),我通过google发现它在math.h中声明(
< a rel =nofollowhref =http://www.gnu.org/software/libc/manual/html_node/Rounding-Functions.html)\"target =_ blank> http://www.gnu.org/软件/的libc /人...... unctions.html)。这个
功能不起作用,我得到一个未引用的符号错误。
函数rint()在包含math.h时有效。
i am trying to use the function round() which I found through
google to be declared in math.h (
http://www.gnu.org/software/libc/man...unctions.html). this
function does not work and i get an unreferenced symbol error. the
function rint() works when math.h is included.
这是在C FAQ中。
14.3:我是试图做一些简单的触发,我是#including< math.h>,
但我一直得到undefined:sin编译错误。
答:确保你实际上是在连接数学库。对于
实例,在Unix下,在编译/链接时,通常需要在命令行的* end *处使用-lm选项。另见
问题13.25,13.26和14.2。
This is in the C FAQ.
14.3: I''m trying to do some simple trig, and I am #including <math.h>,
but I keep getting "undefined: sin" compilation errors.
A: Make sure you''re actually linking with the math library. For
instance, under Unix, you usually need to use the -lm option, at
the *end* of the command line, when compiling/linking. See also
questions 13.25, 13.26, and 14.2.
抱歉没有先阅读常见问题解答。谢谢回复。我使用
#define round(x)((x)> = 0)工作
?(int)((x)+0.5):( int )((x)-0.5)
对C来说是新手,但看起来很奇怪。这种链接只是使用像头文件这样的东西来敲打
。我相信我错过了一些东西。
谢谢
sorry for not having read the FAQ first. thanks for the reply. i worked
around that using
#define round(x) ((x)>=0)?(int)((x)+0.5):(int)((x)-0.5)
am new to C but seems mighty strange.this kind of linking just beats
using something like a header file. i am sure i am missing something.
thanks
m< ma ** @ mschumacher.com>写道:
m <ma**@mschumacher.com> writes:
抱歉没有先阅读常见问题解答。谢谢回复。我使用
#define round(x)((x)> = 0)来解决这个问题?(int)((x)+0.5):( int)((x)-0.5)
sorry for not having read the FAQ first. thanks for the reply. i
worked around that using
#define round(x) ((x)>=0)?(int)((x)+0.5):(int)((x)-0.5)
对于它的价值,它应该可行,但只有当'x''
四舍五入到范围'int''。
-
int main(void){char p [] =" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz。\
\ n",* q =" kl BIcNBFr.NKEzjwCIxNJC" ;; int i = sizeof p / 2; char * strchr(); int putchar(\
); while(* q ){i + = strchr(p,* q ++) - p; if(i> =(int)sizeof p)i- = sizeof p-1; putchar(p [i] \
) ;}返回0;}
For what it''s worth, that should work okay, but only if `x''
rounds to a value in the range of `int''.
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
这篇关于圆的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!