diff --git a/example.c b/example.c new file mode 100644 index 0000000..6d2300c --- /dev/null +++ b/example.c @@ -0,0 +1,57 @@ +#include +#include + +// Function prototypes +static void foo(int n); +static void bar(int n); +static void baz(int n); + +/** + * Main function + * Entry point of the program. + */ +int main(int argc, char *argv[]) { + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return EXIT_FAILURE; + } + + char *endptr; + long input = strtol(argv[1], &endptr, 10); + + if (*endptr != '\0' || input <= 0 || input > INT_MAX) { + fprintf(stderr, "Invalid input. Please provide a positive integer.\n"); + return EXIT_FAILURE; + } + + foo((int)input); + + return EXIT_SUCCESS; +} + +/** + * Function: foo + * Description: Calls the `bar` function. + */ +void foo(int n) { + printf("In foo with n = %d\n", n); + bar(n); +} + +/** + * Function: bar + * Description: Calls the `baz` function. + */ +void bar(int n) { + printf("In bar with n = %d\n", n); + baz(n); +} + +/** + * Function: baz + * Description: Final function in the call chain. + */ +void baz(int n) { + printf("In baz with n = %d\n", n); + // Placeholder for actual logic +}