Mixed 'switch' and 'while' in C
问题 I've recently read this page about strange C snippet codes. Most of them was understandable. But I can't understand this one: switch(c & 3) while((c -= 4) >= 0){ foo(); case 3: foo(); case 2: foo(); case 1: foo(); case 0: } Can anyone please help me out what logic is behind of this code? And how does it work? 回答1: The duff's device comment should explain the background well enough, so I ll try to explain this very case: The switch checks the last 2 bits of c, and jumps to the respective case