Lesson 50 of 50
cBest Practices & Coding Style for C
12 mins
Course progress100%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 50 of 50
c12 mins
Keep these ideas in mind as you work through the lesson.
Consistent style makes code readable and maintainable.
snake_case for variables/functions, PascalCase for types.#ifndef MY_HEADER_H … #endif./** ... */ for API docs; inline // for explanations.size_t for sizes/indices, intptr_t for pointer‑integer casts.const wherever data won’t change.clang‑tidy) and formatting (clang‑format -style=Google).#ifndef UTILS_MATH_H
#define UTILS_MATH_H
/**
* Compute the greatest common divisor (Euclidean algorithm).
*/
int gcd(int a, int b);
#endif // UTILS_MATH_H
clang-format -i *.c *.hclang-tidy with your project config.-Wall -Wextra -Werror (treat warnings as errors).valgrind).