This classic ioccc entry is a Hello World program written in C. Can anyone please provide an explanation of how it works?
Original code (syntax highlighting intentionall
The string index of i["..."] causes the loop to execute for the length of the string. i++ + the hello world string means each iteration passes the string starting one letter deeper to the local read function.
first iteration = "hello.." second iteration = "ello.."
The read function's first parameter simplifies to 0, stdout's file descriptor. The last parameter simplifies to 1, so only one character is written per call. This means each iteration will write the first character of the string passed to stdout. So following the example strings from above:
first iteration = "h" second iteration = "e"
The string index in the for loop is the same length as the hello world string, and as [] is commutative, and strings are null terminated, the last iteration will return the null character and exit the loop.