Below is perhaps the simplest program that will determine the size of a pointer (in bytes). It can give an insight into whether the underlying Operating System and/or architecture is 32- or 64-bit.
int main() { return( sizeof( int* ) ); }
The return value can be queried from the shell with an echo $?
.
The return value is typically a 4 for a 32-bit Linux distribution, or an 8 for a 64-bit distribution.
A slightly fancier version of the above program could be
#includeint main() { printf( "ptr size: %zu\n", sizeof( int *) ); return 0; }
Notes:
sizeof
operator is size_t
.
printf
conversion specification is %zu