Skip to content
Learn Netverks

Lesson

Step 13/36 36% through track

arrays-c

Arrays

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

This lesson

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

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

You will apply Arrays 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.

Arrays are contiguous sequences of the same type. In most expressions, an array decays to a pointer to its first element.

Declaration and indexing

int nums[5] = {1, 2, 3, 4, 5};
int first = nums[0];
int len = sizeof(nums) / sizeof(nums[0]);

sizeof trick works for stack arrays, not pointers returned from functions.

Arrays and pointers

nums[i] is equivalent to *(nums + i). Bounds are not checked—accessing out of range is undefined behavior.

Important interview questions and answers

  1. Q: Array vs pointer?
    A: Arrays have size information at definition; pointers are just addresses—decay loses length unless tracked separately.
  2. Q: Can you assign arrays?
    A: No—array names are not assignable; copy element by element or use memcpy.

Self-check

  1. How do you get the length of a stack array?
  2. What happens if you read nums[100] on a 5-element array?

Tip: Track array length separately when passing pointers—sizeof only works on the array at its definition site, not on decayed pointers.

Interview prep

Array decay?

In most expressions an array name becomes a pointer to its first element—length information is lost unless tracked separately.

Bounds checking?

C does not check array bounds at runtime—out-of-range access is undefined behavior.

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

  • Array decay?
  • Bounds checking?

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