[考古]政大資科88

看板TransCSI作者 (11)時間20年前 (2005/07/06 09:44), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
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

218.170.156.150 07/06, , 1F
用 ++3
218.170.156.150 07/06, 1F
文章代碼(AID): #12opTlp8 (TransCSI)