Home

Search IconIcon to open search

Pointers in C

# Pointer size

The size of a pointer is dependent on the machine for which the code is compiled. On 64-bit computers it’s 64 bits. It also can be different from size_t size, which can hold the size of the largest object.

It’s not guaranteed by the standard that all pointers are the same size. But on practice they are. It’s guaranteed that char * and void * are the same size, all struct * the same size, all union *, etc.

Casting pointers to unsigned long to do various things with them can cause undefined behavior! Whether unsigned long is the same size as a pointer is machine-dependent. Use uintptr_t instead. ^96aaca

# Syntax

Two pointers:

1
int *a, *b;

One pointer, one int:

1
int* a, b; // please don't do this

References: