Iterating Backwards in C

·Hacker News··

Home Iterating Backwards in C David Priver, October 24th, 2026 This is shorter than some of my other posts, but I keep seeing people doing this wrong. It's even worse now in the LLM era. Let's say you have a buffer and a counter and you need to iterate it backwards for some reason: _Bool find_last(size_t count, int *haystack, int needle, size_t *where); Almost everyone can do the forward version on autopilot: for(size_t i = 0; i < count; i++){ if(haystack[i] == needle){ *where = i; return 1;

Read full article →

Related Articles

Google Search is now less than half of Alphabet’s revenue
hubraumhugo · Hacker News · 11h ago
We're releasing the weights of Mistral Large 4
kuberwastaken · Hacker News · 13h ago
H.264 Is Magic (2016)
ea016 · Hacker News · 12h ago
The US added a record 20.2 GWh of battery storage in just 3 months
ljf · Hacker News · 17h ago
We ran AI agent swarms in Minecraft and Mindustry
sandslash · Hacker News · 6h ago