推 Leamars: 用 ++3218.170.156.150 07/06
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