作者wasiseal (11)
看板TransCSI
标题[考古]政大资科88
时间Wed Jul 6 09:54:34 2005
There exist pitfalls to avoid when using macros as
functions in the C programming language.For example, all
of the following three versions of macros are supposed to
compute the square of x.Please give Three examples
(expression) to illustrate that the macros may fail to computer correct
results if we treat macros ad functions the first example should only
fail in case (a), the second example should fail in case(a) and (b),
and the third example will fail in all three cases.
(a)#define SQUARE(x) x * x
(b)#define SQUARE(x) (x)*(x)
(c)#define SQUARE(x) ((x)*(x))
第二个example想不出来.......
先谢谢大家了...题目好长
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.216.112.240
1F:推 Leamars: 用 ++3218.170.156.150 07/06