What Pointer in Data Structure?

1 answer

Answer

1244441

2026-04-30 02:30

+ Follow

No, pointer is not a data type but a reference to an object. Pointers are used to refer back to an object which can be anything from a large data value or a collection of values or objects.


A pointer is a variable and is 4 bytes long because 4 bytes = 32 bits, and all addresses in 32 bit operating systems are 4 bytes long :) , so if you want to store an address somewhere you need 4 bytes. A pointer is just 4 bytes in the memory and in these 4 bytes an address is stored.


If you ask the address of an element, like char, int, etc., the address you will get will be the address of the first byte. Only the first byte is saved in the pointer, and then you can manipulate the upcoming bytes.

For example you declare a structure of 12 bytes and you name it myStruct.
let's say that the address of this structure is the address 0x00400001 <- this is the 1st byte.
The second is 0x00400002 and so on till the 12th byte which is 0x0040000C.

Then you declare a pointer to point to myStruct like that:
myStruct *pointer;
The variable pointer is 4 bytes. It doesn't matter if the structure is 12 bytes or 100 bytes or 1 byte. The address of anything in 32-bit systems is always 4 bytes.
In this example the pointer variable contains the address of myStruct which is 0x00400001 <- the 1st byte of the structure.


The pointer might be a data structure because like any other data types, the pointer is always 4 bytes (in 32-bit systems). For 64bits systems which is 8 bytes, the pointers of a 32bit program would logically be the half of them empty like 0x00000000 00400001

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.