Weirdest Hello world program in C

Has someone ever seen like this ?
https://www.youtube.com/watch?v=hmMtQe_mYr0
Last edited on
Speaking of which:

https://www.ioccc.org/
We plan to hold IOCCC28 in 2022. Sorry for the delay, but we think you will appreciate the re-tooling when it is completed. Stay tuned!

the code:
https://www.ioccc.org/years-spoiler.html

so get to work on some weirdness folks :)

There are 5 or so hello worlds in there. popular topic.
Last edited on
This complete Hello World program assumes a sufficiently-permissive C compiler, GCC or Clang, targeting 64-bit Linux:
1
2
3
4
5
6
7
8
double const __attribute__((section(".text.main"))) main[] =
{
  3.1317447528550576e-300, 2.4759294370535322e-309,
  6.6324079335549225e-311, 4.6176439090376578e-313,
  1.4330621280851394e+214, 1.4979202454304957e+248,
  1.3849770857826423e+219, 1.9656826131736314e-236,
  6.9527650898564922e-310, 2.0730124943962024e-317
};


To compile just say gcc main.c or clang main.c. I also made sure it works using Windows Subsystem for Linux.

Live demo:
https://godbolt.org/z/1Yz73EW8a

Hideously, the compiled program is still some 16K bytes in size by default.
Last edited on
a really simple one. endian matters, not too portable.
1
2
3
4
5
int main()
{
  uint64_t hw[2]{6278066737626506568ull, 143418749551ull};  
  printf("%s",hw);
}
Last edited on
I'll be darned.

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <stdio.h>
#include <stdint.h>

int main ()
{
	uint64_t dx = 0x357620655410;
	
	while (dx)
	{
		putchar (0x726F6C6564574820 >> (((dx >>= 4) & 0377) << 3));
	}
	return 0;
}
Hello World

source: thmm (original post)
Has someone ever seen like this ?
https://www.youtube.com/watch?v=hmMtQe_mYr0
I would have had the indecies be 4 bit values, just because working with nybbles is (usually) significantly easier that with triples (although, that's a very good reason not to use nybbles in this case). I would guess that that's what you actually did the first time, which is why that's how you explained it, and why that's what's in your original code with vpn service https://en.finevpn.org/ (notice also that the value of `dx` is different in the original). Also, in the original, you're missing the single-byte mask...but it works, because the value is being implicitly cast to a single byte anyway.
Last edited on
Topic archived. No new replies allowed.