r/programming • • Jul 25 '26

Writing a (valid) C program without main()

https://labs.iximiuz.com/tutorials/c-program-without-main-a1eea557
193 Upvotes

43 comments sorted by

View all comments

9

u/_kst_ Jul 26 '26

You cannot write a valid portable C program for a hosted implementation without a main function. The language requires it. "The function called at program startup is named main."

As the article demonstrates, there are ways to work around this if you play some system-specific tricks, but they will work only for some particular implementations.

I can replace a portable C hello, world program with an echo hello, world shell command, but then I'm no longer programming in C.

The article does provide some interesting information about how some particular C implementations work, but the title is overblown.