Skip to content
Learn Netverks

Lesson

Step 24/36 67% through track

headers-libraries

Headers and libraries

Last reviewed Jun 1, 2026 Content v20260601
Track mode
server_compiled
Means
Compiled runner
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches Headers and libraries: the syntax, patterns, and safety habits you need before advancing in C.

Teams still ship Headers and libraries in C codebases—skipping it leaves gaps in debugging and code reviews.

You will apply Headers and libraries in contexts like: Kernels, drivers, embedded devices, and performance libraries used by other languages.

Write C in main.c with int main(), click Run on server—the dev runner compiles with cc/gcc -std=c11 and runs the binary; read stderr for compile and linker errors (LEARNING_RUNNER_ENABLED=true).

When you can explain the previous lesson's ideas without copying starter code.

Header files (.h) declare interfaces; source files (.c) implement them. The linker combines compiled objects and libraries into one executable.

Splitting code

/* math_utils.h */
int add(int a, int b);

/* math_utils.c */
int add(int a, int b) { return a + b; }

main.c includes the header; compile both files and link together locally.

Static libraries

ar archives .o files into .a libraries. Shared libraries (.so, .dylib, .dll) load at runtime.

Important interview questions and answers

  1. Q: Header vs source?
    A: Headers expose declarations; sources hold definitions the linker needs exactly once.
  2. Q: What does the linker do?
    A: Resolves symbols across object files and libraries into a final executable.

Self-check

  1. Why use include guards?
  2. What file extension holds object code before linking?

Interview prep

Header vs implementation?

Headers declare interfaces; .c files define functions the linker needs exactly once.

Linker role?

Combines object files and libraries, resolving symbol references into a final executable.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • .h vs .c split?
  • static linkage?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump