Skip to main content

Module 1: C Programming Fundamentals: Mistake Clinic

This clinic turns wrong moves into reusable judgment. Use it after each practice page and again before the quiz or checkpoint.


Module-Specific Mistake Radar

Start with these traps. Replace or extend them with real mistakes from your own work.

Mistake to look forWhere it shows upSymptomRepair evidence
Finishing C Compilation and Mental Model Lab with only a final answerC Compilation and Mental Model LabThe work has no failed case, trace, test, proof gap, or design stress point.Add the smallest broken example and show the repair that changes the result.
Finishing Types, Control Flow, and Functions Workshop with only a final answerTypes, Control Flow, and Functions WorkshopThe work has no failed case, trace, test, proof gap, or design stress point.Add the smallest broken example and show the repair that changes the result.
Finishing Arrays, Strings, and I/O Clinic with only a final answerArrays, Strings, and I/O ClinicThe work has no failed case, trace, test, proof gap, or design stress point.Add the smallest broken example and show the repair that changes the result.
Finishing Code Katas with only a final answerCode KatasThe work has no failed case, trace, test, proof gap, or design stress point.Add the smallest broken example and show the repair that changes the result.
Treating C Is a Portable Assembler as vocabulary instead of a toolC Is a Portable AssemblerThe explanation names the concept but cannot decide between two cases.Write one example, one non-example, and the rule that separates them.
Treating The Translation Pipeline as vocabulary instead of a toolThe Translation PipelineThe explanation names the concept but cannot decide between two cases.Write one example, one non-example, and the rule that separates them.

Practice Mistake Checks

Pull any miss from these checks into your mistake log.

C Compilation and Mental Model Lab

Source: practice/01-c-compilation-and-mental-model-lab.md

For each statement, identify the error:

  1. "The preprocessor imports headers like Python imports modules."
  2. "If the program runs fine in debug mode, there is no undefined behavior."
  3. "The compiler reports every undefined reference it detects."
  4. "gcc -std=c89 means the compiler targets only 32-bit processors."
  5. "A translation unit is the same thing as an executable."

Types, Control Flow, and Functions Workshop

Source: practice/02-types-control-flow-and-functions-workshop.md

For each, identify the error:

  1. if (x = 5) { ... }
  2. #define SQUARE(x) x*x
  3. printf("%d\n", sizeof(int));
  4. int arr[10]; void f(int arr[10]) { size_t n = sizeof arr / sizeof arr[0]; ... }
  5. register int *p = &x;
  6. for (unsigned i = n; i >= 0; i--) { ... }
  7. int *arr = (int*)malloc(sizeof(int)); for (i = 0; i < 10; i++) arr[i] = i;
  8. #define MAX 100; used as for (int i = 0; i < MAX; i++)

Arrays, Strings, and I/O Clinic

Source: practice/03-arrays-strings-and-io-clinic.md

For each, identify the error:

  1. char name[8]; strcpy(name, "Kernighan");
  2. char *s = "hi"; s[0] = 'H';
  3. char buf[100]; sprintf(buf, "%s %s", a, b); where a and b are user input
  4. char buf[100]; fgets(buf, 100, stdin); buf[strlen(buf)-1] = '\0';
  5. int n; scanf("%d", n);
  6. printf(user_input);
  7. char dst[5]; strncpy(dst, "hello world", 5); then puts(dst);
  8. void f(int a[10]) { size_t n = sizeof a / sizeof a[0]; /* loop over n */ }

Repair Protocol

For each real mistake:

  1. Reproduce the failure on the smallest example, trace, proof, query, command, or design sketch.
  2. Name the hidden assumption.
  3. Repair the artifact.
  4. Save evidence that changed: failing then passing test, corrected proof step, revised diagram, safer command, benchmark, or review note.
  5. Add one retrieval card beginning with Check... before... or Do not use... when....

Mistake Log

DateMistakeSymptomRoot causeRepair evidenceRetrieval card
StarterPick one radar row aboveExplain how it would fail in this moduleName the assumptionAdd a counterexample or corrected artifactWrite the card before closing the page

Completion Standard

  • At least five real mistakes are logged.
  • At least two mistakes include a counterexample or failing test.
  • At least one mistake connects to an older semester skill.
  • At least one correction changes code, a proof, a diagram, a command transcript, a query, or a design decision.