Skip to content

Instantly share code, notes, and snippets.

@gboncoffee
Created August 7, 2023 15:03
Show Gist options
  • Save gboncoffee/8a6c7787f329d00ea10e04e9c0024806 to your computer and use it in GitHub Desktop.
Save gboncoffee/8a6c7787f329d00ea10e04e9c0024806 to your computer and use it in GitHub Desktop.
Example of crazy use of multiple calls to main() and cli args.
/*
* Maybe this should be illegal? This is a program that RETURNS the factorial of
* the number of cli args it receives, by recursivelly calling main.
*
* License: The Unlicense License
* Original author: Gabriel G. de Brito
*/
int main(int argc, char *argv[])
{
if (argc == 0)
return 1;
return argc * main(argc - 1, argv);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment