Re: C語言當中...某變數=(敘述1,敘述2);

看板Programming作者 ((short)(-15074))時間15年前 (2008/12/31 07:52), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《yuyuyu.bbs@bbs.ntu.edu.tw (還是小帥哥 ^_^)》之銘言: : 請問這是什麼意思呢?可否解釋一下. : 在國外的網站上看到這種用法, : 書上似乎沒有提到過... : *_* 如果兩個expression以逗號分開且並不是在參數列上的話 則表示兩個式子依序執行 且以後者之值為全式之值 多個逗號連結則由左而右 以最右者為值 要注意的是 , 的優先序是最低的 所以常常需要以()來強制分隔式子 標題的寫法即是敘述1和敘述2依序執行後將敘述2之值指定給變數 維基百科上說它也算做一個sequence point 所以是可以確定前面事情做完後的side effect會先結算再做後面的事 (例如若a=3 則 (a++,a*9) 的結果是36) -- 'You've sort of made up for it tonight,' said Harry. 'Getting the sword. Finishing the Horcrux. Saving my life.' 'That makes me sound a lot cooler then I was,' Ron mumbled. 'Stuff like that always sounds cooler then it really was,' said Harry. 'I've been trying to tell you that for years.' -- Harry Potter and the Deathly Hollows, P.308 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.30.84 ※ 編輯: LPH66 來自: 140.112.30.84 (12/31 07:52) ※ 編輯: LPH66 來自: 140.112.30.84 (12/31 07:53) ※ 編輯: LPH66 來自: 140.112.30.84 (12/31 07:55)

12/31 23:12, , 1F
專業!沒注意可以這樣用! ><
12/31 23:12, 1F
文章代碼(AID): #19MhHJ3p (Programming)
文章代碼(AID): #19MhHJ3p (Programming)