What-is-the-size-of-a-pointer-in-C? tccicomputercoaching.com

Page 1

What-is-the-size-of-a-pointer-in-C? tccicomputercoaching.com The size of a pointer depends on many factors - including the CPU architecture, compiler, Operating System etc. It depends on which compiler you are using. If you are using 16 bit it will be 2. If you are using 32 bit it will be 4. If you are using 64 bit it will be 8.

It is common to all the data types (*int,*char,*flaot, etc‌). 1. #include <stdio.h> 2. int main() 3. { 4. int *ip; 5. print(“pointer size: %zu\nâ€?, sizeof(ip)); 6. } 7. > cc -o pointersize pointersize.c 8. > ./pointersize 9. pointer size: 8 10. > cc -m32 -o pointersize pointersize.c 11. > ./pointersize 12. pointer size: 4


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.