This assignment explores how function calls work at the stack level, demonstrating recursion, stack growth, stack overflow, and function pointer callbacks.
stack_explorer.c: Assignment file with TODO sections to completeREADME.md: This file
Complete all TODO sections in stack_explorer.c:
- Part 1: Basic Recursion - Implement factorial with stack visualization
- Part 2: Stack Depth Tracking - Implement Fibonacci with recursion depth tracking
- Part 3: Stack Overflow Demo - Create and fix stack overflow
- Part 4: Function Pointers - Implement callback-based array processing
- Part 5: Event System - Build callback registration and triggering
Mac/Linux:
gcc stack_explorer.c -o stack_explorer
./stack_explorerWindows:
gcc stack_explorer.c -o stack_explorer.exe
stack_explorer.exeYour completed program should show:
- Factorial calls with stack growing and shrinking
- Fibonacci recursion with depth tracking showing exponential growth
- Stack overflow crash (intentional), then safe version working
- Array processing with different callback functions
- Event system registering and triggering multiple callbacks
Part 3 asks you to implement infinite_recursion which will deliberately crash your program with a stack overflow. This is expected! After observing the crash, comment out the call to infinite_recursion in main before continuing to test the rest of your code.
Submit:
- GitHub repository URL with your completed
stack_explorer.c - Reflection document (
reflection.txtorreflection.md) with 350-500 words