C in 100 Seconds: Pass by Reference — Pointers as Parameters | Episode 19
7views
002:44
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
C passes everything by value — the function gets a copy, not the original. A swap function that takes plain ints looks right but changes
nothing. Pass pointers instead, and the function can reach the caller's variables through dereferencing.
no_swap copies the values — x and y stay the same. swap takes addresses with ampersand and dereferences with star — x and y actually flip.
Pointers let functions reach outside themselves.
Student code: https://github.com/GoCelesteAI/c-in-100-seconds/tree/main/episode19
What You'll Learn:
• C passes by value — functions get copies
• Pointers as parameters — int *a instead of int a
• Ampersand passes the address — swap(&x, &y)
• Star dereferences — *a reads/writes the original
• The classic swap demo: why it fails and how to fix it
Next: Episode 20 — malloc and free
#c #programming #100seconds #learnc #passbyreference #pointers #swap #dereference #tutorial
Tags
c pass by reference, pointers c, swap function c, pass by value vs reference, dereference c, ampersand c, c tutorial 2026, c beginner, 100
seconds, learn c, coding tutorial
Tags
c pass by referencepointers cswap function cpass by value vs referencedereference campersand cc tutorial 2026c beginner100 secondslearn ccoding tutorial