The “type” of data that pointers hold in the C language

cpointers

I know that pointers hold addresses. I know that pointers' types are "generally" known based on the "type" of data they point to. But, pointers are still variables and the addresses they hold must have a data "type". According to my info, the addresses are in hexadecimal format. But, I still do not know what "type" of data is this hexadecimal. (Note that I know what a hexadecimal is, but when you say 10CBA20, for example, is this string of characters? integers? what? When I want to access the address and manipulate it .. itself, I need to know its type. This is why I am asking.)

Best Answer

The type of a pointer variable is .. pointer.

The operations you're formally allowed to do in C are to compare it (to other pointers, or the special NULL / zero value), to add or subtract integers, or to cast it to other pointers.

Once you accept undefined behaviour, you can look at what the value actually is. It will usually be a machine word, the same kind of thing as an integer, and can usually be losslessly cast to and from an integer type. (Quite a lot of Windows code does this by hiding pointers in DWORD or HANDLE typedefs).

There are some architectures where pointers are not simple because memory is not flat. DOS/8086 'near' and 'far'; PIC's different memory and code spaces.