DEV Community

Austin Williams
Austin Williams

Posted on • Updated on

A Quick and Dirty Primer to Pointers in C/C++

Note: This is not meant to teach you how everything works under the hood. This is just for understanding the syntax of pointers and for giving good intuition on how to read and write code which utilizes them.

Anyways,
I was going through some old notes and found a bunch of stuff I wrote about pointers and remembered I had an account on here and figured "why not throw something out there", so here ya go.

Terminology

Pointer: A variable which holds the address of another variable.
Reference: Setting a pointer to equal the address of a variable.
De-Reference: Reading or Writing to the value at the address pointed to by a pointer.

Examples

Modifying a variable via pointer

Passing by Reference vs Passing by Value

Pointers to Pointers

Pointer Arithmetic

Quick Note About Multiple Pointers in One Line

References Used

https://denniskubes.com/2017/01/24/the-5-minute-guide-to-c-pointers/
https://stackoverflow.com/questions/14224831/meaning-of-referencing-and-dereferencing
https://www.studytonight.com/c/pointer-to-pointer.php
https://stackoverflow.com/questions/11598361/why-a-pointer-1-add-4-actually

In Closing

There you go.
This was pretty fun to write up. Maybe I'll do some more little
primers like this. Hopefully someone found it useful, as
this is all admittedly pretty elementary.

Top comments (0)