Basic computer course, C programming language, Education, Engineering Course, Engineering Courses, Maths Coaching, online computer coaching, PGDCA course coaching, programming course, school computer coaching, training, Uncategorized, Web Design course

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.

C-Programming-pointer

It is common to all the data types (*int,*char,*flaot, etc…).

1. #include <stdio.h>

2.int main()

3. {

4. int *ip;

5. printf(“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

Pointer size depends only on the model under which you are compiling your code. Not on the operating system. So I do have a 64bit Linux, but if I force gcc to compile 32bit code, I get 32bit ELF and i386 code with just 4 bytes pointer size.

But also on modern computers you can have different pointer sizes.

A modern 64 bit Intel/AMD PC still runs 8086 programs with 16/20/32 bit pointer sizes.

Even with modern programming tools it can have different pointer sizes. Many programs still basically are written for 32 bit OS’es, which typically can be run without any problems on a 64 bit OS.

This is most useful concept Pointer in C Programming Language.

To learn more about Programming Languages at TCCI.

Call us @ 9825618292

Visit us @ http://tccicomputercoaching.com/course/

 

Leave a comment