---
title: "pointer"
type: concept
related: [Objects, Pointer]
source: https://www.jemoka.com/posts/kbhpointer/
confidence: high
status: active
---

A pointer is a variable which stores memory addresses. Because there are no pass-by reference, we use pointers to emulate pass by reference: by sharing addresses with other functions.
A pointer can identify a single byte OR some large data structures. We can dynamically allocate pointers, and also identify memory generically without types.
C is always pass-by-copy. Therefore, to pass-by-reference, you basically have to
int x = 2; // declare object int *xptr = &amp;x; // get location of object (&amp;: address of) printf(&#34;%d\n&#34;, *xptr); // dereference the pointer address operator You will note, in the line above:
int *xptr = &amp;x; uses an operator &amp; to get the address of an object. That&rsquo;s called an object operator.
pointer memory diagram void myFunct(int *intPtr) { *intPtr = 3; } int main() { int x = 2; myFunct(&amp;x); }
