<story><title>C implementation of Tic-Tac-Toe in a single call to printf (2020)</title><url>https://github.com/carlini/printf-tac-toe</url></story><parent_chain></parent_chain><comment><author>st_goliath</author><text>A few key points (also mentioned in the README): The &amp;quot;%n&amp;quot; specifier makes printf() fetch an int* argument and write the number of characters written so far to the target location. The funky stuff happens when you abuse that to overwrite the format string itself, actually making printf() Turing-complete.&lt;p&gt;This also means that if you lazily stuff a user controller string into a printf() style function (instead of doing e.g. `printf(&amp;quot;%s&amp;quot;, str)`), this can be used as a gadget for arbitrary memory writes (in addition to arbitrary stack reads). For this reason, there are compiler warnings if you use a format string that isn&amp;#x27;t a string literal (IIRC now on by default in GCC 11) and some C libraries like dietlibc refuse to implement %n.</text></comment>
<story><title>C implementation of Tic-Tac-Toe in a single call to printf (2020)</title><url>https://github.com/carlini/printf-tac-toe</url></story><parent_chain></parent_chain><comment><author>snickerer</author><text>This is a fine joke, and a it is a piece of art. I laughed and I think it is beautiful.&lt;p&gt;The authors did not only used printf() as a Turing-complete language, they also formatted their source code in a way pleasing to the eye. Cheers!&lt;p&gt;Don&amp;#x27;t forget coding is an art of fun and mystery, created to learn and play!</text></comment>