A hands-on collection of small C tutorials focused on foundational systems programming patterns: arrays, command-line tools, JSON parsing, network scripting, and shared library workflows.
- Project Goals
- Repository Layout
- Prerequisites
- Quick Start
- Tutorials
- Build System Notes
- Coding and Runtime Notes
- Troubleshooting
- Suggested Learning Path
- Contributing
- License
This repository is designed for learners who want practical, minimal examples of C development workflows.
You will practice:
- Writing and compiling small C programs.
- Using
maketo automate build/clean/test scaffolding. - Parsing command-line options.
- Integrating external C libraries (Jansson JSON parser).
- Building and consuming shared libraries (
.so).
C-Style-Adventures/
├── README.md
├── arrays/
├── ascii_tools/
├── json_parser/
├── network_tools/
└── shared_libs/
├── ex1/
└── ex2/
Each tutorial directory includes source files, a Makefile, and local documentation (README.md).
- Linux/Unix-like environment (recommended)
gcc(or another C compiler)make- Standard shell utilities (
rm,cp,date,ping, etc.)
libjansson-dev(or equivalent package for your distribution)
Debian/Ubuntu example:
sudo apt-get update
sudo apt-get install -y build-essential libjansson-devClone and build a tutorial:
git clone <your-fork-or-repo-url>
cd C-Style-Adventures
cd arrays
make all
./session/multidimensionalMost tutorials follow this pattern:
cd <tutorial-directory>make all- Run binary from
session/
Directory: arrays/
Program: multidimensional
Demonstrates declaration and traversal of a 2D integer array with nested loops.
Run:
cd arrays
make all
./session/multidimensionalSee full tutorial details in arrays/README.md.
Directory: ascii_tools/
Program: charfinder
Simple CLI utility demonstrating argument parsing and character-to-ASCII conversion.
Run:
cd ascii_tools
make all
./session/charfinder -h
./session/charfinder -i ASee full tutorial details in ascii_tools/README.md.
Directory: json_parser/
Program: json_parser
Introduces JSON parsing in C via Jansson (json_loads, object field lookup, cleanup).
Run:
cd json_parser
make all
./session/json_parserIf build fails with missing jansson.h, install Jansson development headers first.
See full tutorial details in json_parser/README.md.
Directory: network_tools/
Program: pingnet
Demonstrates a switch-based command dispatcher for pinging hosts and appending output to a log.
Run:
cd network_tools
make all
./session/pingnet -h
./session/pingnet -p 5
./session/pingnet -vSee full tutorial details in network_tools/README.md.
Directory: shared_libs/ex1/
Library: libmeso.so
Executable: session/sharedtest
Shows a local shared-library flow using PIC objects and runtime rpath.
Run:
cd shared_libs/ex1
make all
./session/sharedtestSee full tutorial details in shared_libs/ex1/README.md.
Directory: shared_libs/ex2/
Library: libutils.so
Executable: session/sharedtest
Demonstrates a shared-library flow that copies the built library into /usr/lib.
Run:
cd shared_libs/ex2
make all
./session/sharedtestNote: this flow modifies system library paths and may require elevated privileges.
See full tutorial details in shared_libs/ex2/README.md.
- Most tutorial Makefiles expose:
clean,compile/build, andtesttargets. - Output binaries are generally placed in a local
session/directory. - Some examples use strict compile flags (
-Wall -Werror), especially shared library examples.
- Tutorials are intentionally minimal and educational rather than production-hardened.
- Some examples rely on shell commands executed from C (
system(...)). - Platform behavior can differ between Linux/macOS/Windows shells.
- For safer production code, prefer:
- explicit input validation,
- bounded string functions (
snprintf), - and process APIs over shell command composition.
Install Jansson development headers/libraries for your platform and re-run make in json_parser/.
The linker cannot find a required library. Verify the library is installed and in the expected library search path.
If executable cannot load .so files, check:
rpathusage in linker flags,- system library cache/path configuration,
- file placement and permissions.
shared_libs/ex2 may require privileges depending on your environment.
arrays/(core syntax and iteration)ascii_tools/(CLI argument basics)json_parser/(external dependency integration)network_tools/(multi-command utility patterns)shared_libs/ex1/(local shared library fundamentals)shared_libs/ex2/(system-level library deployment pattern)
Contributions are welcome. Helpful improvements include:
- hardening input validation and error handling,
- improving cross-platform behavior,
- expanding automated tests in
testtargets, - and adding new focused C tutorials.
Individual files may contain their own licensing notices. Review source headers before redistribution.