Quantcast
Channel: Tips for golfing in C - Code Golf Stack Exchange
Viewing all articles
Browse latest Browse all 67

Answer by Bubbler for Tips for golfing in C

$
0
0

Abuse dark corners of array indexing

enter image description here

i[array] desugars into *(i+array), and since + is commutative for pointer+integer too, it is equivalent to *(array+i) and therefore array[i].

It's not very common to see an array indexing expression (whatever)[x] where whatever requires wrapping in parens and x doesn't, but when you see one, you can swap the two positions and write x[whatever] to save two bytes.

A real golfing example.


Viewing all articles
Browse latest Browse all 67

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>