所以,我發現了一段時間以來一直困擾着我的東西。我對C語言還很陌生。C中指針的奇怪互動
,我講的代碼是在這裏,它的strcmp的實現:http://pastebin.com/VeHGm8sD
有關此計劃的奇怪的是,如果你在線路12分別爲13
*first_string++; // should increment value of char ??
*second_string++;
改變
first_string++; // should increment address
second_string++;
但是它們都增加地址。這怎麼可能?
請閱讀[運算符優先順序](http://en.cppreference.com/w/c/language/operator_precedence)。 postincrement操作符的優先級位於圖表的最上方,高於解引用操作符的頂端。 –
很難理解'* first_string ++;'意圖是什麼。顯然他們想增加'first_string'。那麼爲什麼那裏有'*'呢? –
這是一個很好的觀點,@DavidSchwartz。鏈接的'strcmp()'實現看起來有點兇狠 - 好像一個更簡潔的書寫版本被笨拙地重寫,試圖使它更清晰。 –