Elektrine lite

← Feed

@mos_8502@studio8502.ca

Post #3868482

2026-07-16 20:44 UTC

What I do is, I have main.c which (obviously) contains the main() function, but it also contains static functions setup() and quit(), which, respectively, handle setting up the initial program state and cleaning up anything that needs cleaning up before exit. Generally, my main.c looks something like this: #include "foo.h" static void quit() { } static void setup() { } int main(int argc, char **argv) { setup(); // In a GUI program, this is where I'd enter the main loop quit(); }

Replies (1)

  • @mos_8502@studio8502.ca 2026-07-16 20:46

    As a rule of thumb, I like to keep my function bodies as short as possible. Once it gets to a full screen of code, the function is probably too big and should probably be refactored.

    Open ##3868481