Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
cd96195
Revise introduction in README for clarity and emphasis on learning ap…
ajithakdev May 26, 2026
1ccc3be
chore: restructure repo into topic-based dirs + extend .gitignore
ajithakdev May 26, 2026
807d76e
feat(lessons): add 19 lessons across 8 topics with topic READMEs
ajithakdev May 26, 2026
4dcd0dc
feat(mnemonics): add ASCII memory aids for pointers, malloc, strings,…
ajithakdev May 26, 2026
a405f89
feat(patterns): add bubble-sort, file-read-lines, malloc-cleanup snip…
ajithakdev May 26, 2026
8aabc02
feat(challenges): tier challenges into foundational/pointers/integrat…
ajithakdev May 26, 2026
8a36e51
feat(practice): add 15 tiered practice problems with skeletons
ajithakdev May 26, 2026
8f2a855
feat(projects): add capstone expression evaluator + tests + READMEs f…
ajithakdev May 26, 2026
fa3d193
feat(infra): Makefile + compile_check + test_lessons + golden outputs
ajithakdev May 26, 2026
55c1a47
feat(ci): GitHub Actions for compile-check + test, PR template with c…
ajithakdev May 26, 2026
8479e56
docs: rewrite README, refresh ONBOARDING, add CONTRIBUTING + docs/ de…
ajithakdev May 26, 2026
a2d232c
fix(tests): keep trailing space in two goldens to match actual stdout
ajithakdev May 26, 2026
3a165b9
chore: force LF line endings via .gitattributes (golden output byte-e…
ajithakdev May 26, 2026
892a683
fix(lessons): print space-separated lists without trailing space
ajithakdev May 26, 2026
e72498e
fix(tests): strip stale trailing space from arrays-as-pointers golden
ajithakdev May 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
* text=auto eol=lf
*.c text eol=lf
*.h text eol=lf
*.sh text eol=lf
*.md text eol=lf
*.yml text eol=lf
*.txt text eol=lf
Makefile text eol=lf
30 changes: 30 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## What changed
<!-- 1-3 bullets. What + why. No essay. -->
-

## Type
<!-- check one -->
- [ ] new lesson / practice / pattern
- [ ] fix (compile / output / typo)
- [ ] docs
- [ ] infra (Makefile / CI / tests)

---

## Developer checklist

- [ ] `make compile-check` passes locally
- [ ] `make test` passes locally
- [ ] New `.c` file follows lesson template (≤30 lines, output-first, BREAK IT)
- [ ] If deterministic: added matching `tests/expected_outputs/<key>.txt`
- [ ] Linked from the topic `README.md` (if a new lesson)
- [ ] No secrets, no personal data, no large binaries

## Reviewer checklist

- [ ] CI green (compile-check + test)
- [ ] Tone matches repo (punchy, no fluff, no "learning journey")
- [ ] WHY comments only, no WHAT narration
- [ ] Memory diagram present where pointers/memory touched
- [ ] Golden output matches reality (not aspirational)
- [ ] No dead refs (links, file paths)
17 changes: 17 additions & 0 deletions .github/workflows/compile-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: compile-check

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
compile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install gcc
run: sudo apt-get update && sudo apt-get install -y gcc
- name: Compile every .c file
run: make compile-check
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: test

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install gcc
run: sudo apt-get update && sudo apt-get install -y gcc
- name: Run lesson test suite
run: make test
- name: Fail loudly if any lesson broke
if: failure()
run: |
echo "::error::A lesson failed to compile or output drifted. PR rejected."
exit 1
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ a.out
*.o
*.obj

# Phonebook project data
# Test runner artifacts
tests/.build/

# Project local data
projects/phonebook/book.txt
projects/guess/best_score.txt

# Editor / OS
.vscode/
Expand All @@ -19,3 +23,7 @@ Thumbs.db
*.dSYM/
*.pdb
*.ilk

# Solutions hidden until requested
challenges/solutions/*.c
!challenges/solutions/README.md
80 changes: 80 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Contributing to CNoBS

Welcome. Two rules: don't break the build, follow the template.

---

## Hard rules

1. Every `.c` file MUST compile cleanly with `gcc -Wall -Wextra -std=c11`.
2. Every lesson MUST pass `make test`.
3. If you add a deterministic lesson, you MUST add a matching golden file in [tests/expected_outputs/](tests/expected_outputs/).
4. No PR merges if CI fails. Fix it locally first.

---

## Lesson template

```c
/*
* Lesson: [topic] | Time: ~N min | Difficulty: easy|medium
* Why this matters: [one sentence, no fluff]
*
* Run: gcc file.c && ./a.out
*
* EXPECTED OUTPUT:
* ------------------------------------------
* [exact stdout]
* ------------------------------------------
*
* MEMORY DIAGRAM (if pointers / memory relevant)
*/

#include <stdio.h>
/* code: 30 lines MAX */

/*
* Why it works: [one paragraph]
*
* BREAK IT:
* 1. [change X, predict, run]
* 2. ...
*/
```

Hard cap: 30 lines of actual code per lesson. If you need more, it belongs in `patterns/` or `projects/`.

---

## Workflow

1. Fork.
2. Branch: `git checkout -b lesson/my-topic`.
3. Write the lesson + the expected_outputs file.
4. Run locally:
```bash
make compile-check
make test
```
5. Both green? Push. Open PR against `main`.
6. CI runs the same checks. Green = mergeable.

---

## Tone

- Punchy. Sarcastic when honest. Never condescending.
- Comments explain WHY, not WHAT.
- No "learning journey" language. No emojis (unless asked).
- Errors fail LOUDLY.

---

## Bug reports

A `.c` file doesn't compile? That's a bug. Open an issue with:
- OS + compiler version
- Exact command run
- Exact error output

Maintainer: [ajithakdev](https://github.com/ajithakdev) · ajithkumarks2579@gmail.com / cseajithak@gmail.com
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
CC ?= gcc
CFLAGS ?= -Wall -Wextra -std=c11 -O0 -g

.PHONY: all test compile-check clean help

all: test

help:
@echo "Targets:"
@echo " make compile-check Compile every .c file (no run). Fails on warning."
@echo " make test Compile + run + diff against expected_outputs."
@echo " make clean Remove built binaries."

compile-check:
@bash scripts/compile_check.sh

test:
@bash tests/test_lessons.sh

clean:
@find . -type f \( -name "*.o" -o -name "a.out" -o -name "*.exe" \) -delete
@rm -rf tests/.build
@echo "clean."
48 changes: 29 additions & 19 deletions ONBOARDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,26 @@ cd CNoBS

### Windows (PowerShell, using clang)
```powershell
cd lessons
clang 01-output-first.c -o out.exe
cd lessons/00-basics
clang 01-types-and-output.c -o out.exe
./out.exe
```
One-liner:
```powershell
clang 01-output-first.c -o out.exe; if ($?) { ./out.exe }
clang 01-types-and-output.c -o out.exe; if ($?) { ./out.exe }
```

### Windows (PowerShell, using gcc from MSYS2)
```powershell
cd lessons
gcc 01-output-first.c -o out.exe
cd lessons/00-basics
gcc 01-types-and-output.c -o out.exe
./out.exe
```

### macOS / Linux / WSL / Git Bash
```bash
cd lessons
gcc 01-output-first.c && ./a.out
cd lessons/00-basics
gcc 01-types-and-output.c && ./a.out
```
(Use `clang` instead of `gcc` on macOS if you prefer — same flags.)

Expand All @@ -99,18 +99,28 @@ If you see that — setup done. You're coding C.
Do them in order. Each takes 10-15 min.

```
lessons/01-output-first.c <- start
lessons/02-pointers-visual.c
lessons/03-arrays-memory.c
lessons/04-structs.c
lessons/00-basics/ <- start: types, ops, control flow
lessons/01-functions/ <- define, call, scope
lessons/02-pointers/ <- the hard part (6 lessons, take your time)
lessons/03-memory/ <- stack vs heap, malloc/free
lessons/04-strings/ <- char arrays, the \0
lessons/05-structs/ <- your own types
lessons/06-file-io/ <- read + write files
lessons/07-advanced/ <- typedef, unions, bit ops
|
challenges/01-fix-the-loop.c <- find + fix bugs
challenges/02-pointer-puzzle.c
challenges/ <- tiered break-it labs
practice/ <- bonus problems with skeletons
patterns/ <- real copy-paste snippets
|
patterns/string-search.c <- real-code snippet
|
projects/guess/guess.c <- first real program
projects/phonebook/phonebook.c
projects/guess/ <- first real program
projects/phonebook/ <- structs + file I/O combined
projects/capstone/ <- expression evaluator (final)
```

After setup, also try the local test runner:
```bash
make compile-check
make test
```

**How to use a lesson:**
Expand All @@ -131,8 +141,8 @@ If a lesson takes more than 20 min, skip the BREAK IT and come back. Don't stall
| `'gcc' is not recognized` (Windows) | Compiler not on PATH. Reopen terminal after install. Or use `clang`. |
| `&&` parser error in PowerShell 5.1 | Use `; if ($?) { ... }` instead. Or upgrade to PowerShell 7. |
| `a.out` not found on Windows | Windows builds `a.exe`. Use `./a.exe` or compile with `-o name.exe`. |
| Segfault | You dereferenced a bad pointer. Go back to [lessons/02-pointers-visual.c](lessons/02-pointers-visual.c). |
| Garbage output | Probably uninitialized variable or buffer overrun. Read the BREAK IT note in lesson 03. |
| Segfault | You dereferenced a bad pointer. See [lessons/02-pointers/06-common-pointer-bugs.c](lessons/02-pointers/06-common-pointer-bugs.c) + [docs/SEGFAULT_DEBUGGING.md](docs/SEGFAULT_DEBUGGING.md). |
| Garbage output | Probably uninitialized variable or buffer overrun. See the BREAK IT note in [lessons/02-pointers/03-arrays-as-pointers.c](lessons/02-pointers/03-arrays-as-pointers.c). |
| `undefined reference to ...` | Forgot to `#include` a header, or function name typo. |

---
Expand Down
Loading
Loading