Created
August 7, 2023 15:03
-
-
Save gboncoffee/8a6c7787f329d00ea10e04e9c0024806 to your computer and use it in GitHub Desktop.
Example of crazy use of multiple calls to main() and cli args.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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