Philosophy and "for" loops — more from Go and Rust
Philosophy and "for" loops — more from Go and Rust
Posted Jul 4, 2013 12:55 UTC (Thu) by guus (subscriber, #41608)In reply to: Philosophy and "for" loops — more from Go and Rust by wahern
Parent article: Philosophy and "for" loops — more from Go and Rust
You can also use nested C99 for loops to create more variables, like:
for (char *foo = (char *)1; foo; foo = NULL)
for (int x = 0, foo = "bar"; ...; ...) {
printf("x = %d, foo = %s\n", x, foo);
}
The outer for loop will only run once. GCC will notice this and will completely optimize it away. This is very useful in macros.
