In Lesson 4 of Learn C With Me, we tackle one of the most infamous — and important — concepts in C programming: pointers.
Using Beej's Guide to C as our study material, we start from the very beginning: how variables are stored in memory, what memory addresses actually represent, and how a pointer allows us to refer to data indirectly.
Memory, variables and addressesHow data is stored in memoryA brief look at endiannessWhat a pointer actually isThe address-of operator (&)Printing addresses with %pPointer typesDeclaring and initializing pointersPointers to different data typesDereferencing pointers with *The difference between a pointer and the value it points toModifying variables through pointersPassing pointers as function argumentsUsing pointers to modify variables outside a function's local scopeThe NULL pointerWhat happens when you dereference a null pointerA brief look at nullptr in C23Pointer declaration syntax and some of its potential pitfallsUsing sizeof with pointersPointers to pointersAlong the way, we experiment with the code ourselves and spend plenty of time trying to build an intuitive understanding of what pointers actually mean rather than simply memorizing the syntax.
We also see our first really practical reason for using pointers: overcoming C's pass-by-value behavior by passing a variable's address to a function, allowing that function to modify the original variable.
As usual, there are mistakes, questions, compiler warnings, a segmentation fault or two, and plenty of help from the live chat while we figure things out together.
This is an interactive, follow-along live course. I am learning C alongside you, so expect questions, mistakes, experiments and plenty of discussion. No passive watching here — participate in the chat and work through the examples with us.
📅 We go live every Saturday at 19:00 CEST — interactive, follow-along C programming sessions.
Linux Renaissance C Programming Course
📺 All C Programming lessons:
🔴 This stream is proudly sponsored by OPNsense — the open source firewall and routing platform trusted by professionals worldwide.
Support Linux Renaissance
🛒 Shop: Linux Renaissance Shop
☕ Ko-fi: Ko-fi
🎖️ Patreon: Patreon
▶️ YouTube membership: YouTube Membership
Find me elsewhere
🌐 Blog: Linux Renaissance
🎥 PeerTube: Linux Renaissance on PeerTube
📺 Odysee: Linux Renaissance on Odysee
🎮 Twitch: Linux Renaissance on Twitch
💬 Matrix: Linux Renaissance Matrix space