There was an IOCCC entry for a similar "smallest C program that emits its own source code" challenge and someone won "best abuse of the rules" by submitting an empty file.
While an interesting post, I find the final answer very unsatisfying as it's not really C but all inline assembly.
Also, WTF about how you created the post. The entire contents of the text post is a URL so it should have been a link. Then the link was to another discussion which required following another link.
Can still fire up Turbo C in a DOSBox and generate ridiculously tiny *.com files. You might have loved the DOS era? ( It's actually not completely finished -- yet ).
More here -- apparently the smallest is 2 bytes per this post.
I just had a flashback to writing some terrible assembly in a .com file. I think a Fibonacci sequence of like the first five values because it was 16bit
22
u/AndrewBorg1126 Jun 06 '26
A binary is not C.
Do you mean combination of conforming c compiler (and optional flags) and valid C source code which creates the smallest binary?
132
u/ParsingError Jun 06 '26
There was an IOCCC entry for a similar "smallest C program that emits its own source code" challenge and someone won "best abuse of the rules" by submitting an empty file.
https://www.ioccc.org/1994/smr/index.html
34
u/TheOtherBorgCube Jun 06 '26
The actual content, not the redirect.
https://blog.weineng.me/posts/smallest_c/
9
u/moocat Jun 06 '26
While an interesting post, I find the final answer very unsatisfying as it's not really C but all inline assembly.
Also, WTF about how you created the post. The entire contents of the text post is a URL so it should have been a link. Then the link was to another discussion which required following another link.
8
u/ceene Jun 06 '26 edited Jun 08 '26
So, that's not C, that's assembly.
11
u/greg-spears Jun 06 '26
Can still fire up Turbo C in a DOSBox and generate ridiculously tiny *.com files. You might have loved the DOS era? ( It's actually not completely finished -- yet ).
More here -- apparently the smallest is 2 bytes per this post.
5
u/Kokowaaah Jun 06 '26
Down to 120 B
1
u/sohang-3112 Jun 06 '26
Good post