A collection of C programming challenges designed to help you master C concepts. Each challenge focuses on real-world programming skills including memory management, data structures, concurrency, and system programming.
- Warm-up: Introduction to challenge structure
- Easy: Basic pointers, arrays, strings, and simple structs
- Medium: Dynamic memory, data structures, function pointers
- Hard: Concurrency, custom memory management, generic programming
- Extreme: Lock-free data structures, advanced system programming
- GCC compiler
- CMake (version 3.10 or higher)
- CMocka testing framework
- Clone this repository:
git clone https://github.com/your-username/advanced-c-challenges.git
cd advanced-c-challenges- Install dependencies:
# Ubuntu/Debian
sudo apt-get install cmocka-dev cmake
# macOS
brew install cmocka cmake
# Or build CMocka from source
git clone https://gitlab.com/cmocka/cmocka.git
cd cmocka && mkdir build && cd build
cmake .. && make && sudo make install- Run all tests:
make test- Navigate to any challenge directory:
cd challenges/easy/001-array-sum- Read the challenge description:
cat README.md- Implement the functions in a new file (e.g.,
solution.c):
#include "challenge.h"
int array_sum(int* arr, size_t size) {
// Your implementation here
return 0;
}- Build and test:
make testadvanced_c/
βββ challenges/
β βββ warm-up/ # 1 challenge
β βββ easy/ # 5 challenges
β βββ medium/ # 5 challenges
β βββ hard/ # 4 challenges
β βββ extreme/ # 3 challenges
βββ scripts/ # Utility scripts
βββ Makefile # Root build system
βββ README.md # This file
Each challenge includes comprehensive CMocka tests that verify:
- Correct functionality
- Memory safety
- Edge cases
- Error handling
Run tests with:
make test # All challenges
make test-easy # Easy challenges only
make test-medium # Medium challenges only
make test-hard # Hard challenges only
make test-extreme # Extreme challenges only- Pointer arithmetic and dereferencing
- Array manipulation
- String operations
- Basic memory allocation
- Simple data structures
- Dynamic memory management
- Complex data structures (trees, hash tables)
- Function pointers and callbacks
- Memory pools
- Generic programming basics
- Thread-safe programming
- Custom memory allocators
- Generic containers
- Signal handling
- System programming
- Lock-free data structures
- Memory debugging tools
- Coroutines and fibers
- Compiler features
- Low-level optimization
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-challenge - Add your challenge following the existing structure
- Ensure all tests pass:
make test - Submit a pull request
- Create a new directory in the appropriate difficulty folder
- Add
README.mdwith challenge description - Create
challenge.hwith function signatures - Write
test_challenge.cwith CMocka tests - Add a
Makefilefor the challenge - Update the root
Makefileto include your challenge
- C Programming Language
- Advanced Programming in the UNIX Environment
- Expert C Programming
- CMocka Documentation
This project is licensed under the MIT License - see the LICENSE file for details.