Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are different pointers considered to be different data types?

Tags:

c

types

pointers

In order to have better understanding of pointers, I'd like to have this cleared up. Different data types require different pointers, like char* or int*. Are all these pointers considered to be different data types or are they just the same data type?

like image 987
Kaiyaha Avatar asked Aug 06 '26 11:08

Kaiyaha


1 Answers

Are different pointers considered to be different data types?

Yes.

Different data types require different pointers, like char* or int*. Are all these pointers considered to be different data types or are they just different types of the same data type?

All are pointers, but their type is different when they point to objects of different type.

Note that beside the difference of the type of the pointer; their size in memory can also be different:

  • Are there any platforms where pointers to different types have different sizes?

  • Is the sizeof(some pointer) always equal to four?

  • Are all data pointers the same size in one platform for all data types?

  • Can pointers be of different sizes?

  • How many bytes do pointers take up?

Also there is nothing like "different types of the same data type". Either the type is different or it is the same.

like image 133
RobertS supports Monica Cellio Avatar answered Aug 08 '26 03:08

RobertS supports Monica Cellio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!