sizeof(void*) will tell you this.
> Some sources says that size of a pointer will always be 2 bytes because
> it just stores the address while some resources say that it is 2, 4, 8
> in 16, 32, 64 bit platform.
2, 4, 8. The size must be large enough to address the entire address space.
> Please varify with a solid reason.
>
> --
> Richa Gupta
> (IT-BHU,India)
>
> --~--~---------~--~----~------------~-------~--~----~
> Visit http://www.gowrikumar.com for good puzzles in C programming
> language and programming interview questions.
>
> You received this message because you are subscribed to the Google
> Groups "Programming Puzzles" group. To post to this group, send email to
> programmi...@googlegroups.com
> -~----------~----~----~----~------~----~------~--~---
>
--
//*David Sveningsson [eXt]*
Freelance coder | Game Development Student
http://sidvind.com
Thou shalt make thy program's purpose and structure clear to thy fellow
man by using the One True Brace Style, even if thou likest it not, for
thy creativity is better used in solving problems than in creating
beautiful new impediments to understanding.
richa gupta wrote:> *size of a pointer in 16 bit platform, 32 bit platform and 64 bit platform.*
> can someone tell me following answer?
>
sizeof(void*) will tell you this.
2, 4, 8. The size must be large enough to address the entire address space.
> Some sources says that size of a pointer will always be 2 bytes because
> it just stores the address while some resources say that it is 2, 4, 8
> in 16, 32, 64 bit platform.
> >
> Please varify with a solid reason.
>
> --
> Richa Gupta
> (IT-BHU,India)
>
--
//*David Sveningsson [eXt]*
Freelance coder | Game Development Student
http://sidvind.com
Thou shalt make thy program's purpose and structure clear to thy fellow
man by using the One True Brace Style, even if thou likest it not, for
thy creativity is better used in solving problems than in creating
beautiful new impediments to understanding.
On the same setup all pointers are of equal size. It doesn't matter if
it is a void-pointer, int-pointer, float-pointer, pointer to a large
struct, pointer to a character array, function-pointer or a
int-pointer-pointer-pointer. They are *all of equal size*.
> What will the size of void* in a 64 bit platform?
8 bytes. Try it yourself with printf("%d\n", sizeof(void*));
> (Actuly this ques was asked in an interview. The interviewer gave me
> three options 2, 4 and 8 for for all the three ( 16, 32, 64 bit platform). )
16-bit has 2 byte pointers
32-bit has 4 byte pointers
64-bit has 8 byte pointers
> As far as i know pointer size is always equal to the word size of the
> machine. So it must be 2,4, 8 for 16, 32, 64 bit platform.
The wordsize is *not* equal to the pointer size. On x86 the a word is 16
bits and a dword is 32 bits.
There are multiple books and article written about these concepts if you
are intrested. I suggest reading "What Every Programmer Should Know
About Memory" [1] by Ulrich Drepper.
There is also a good blog [2] by Gustavo Duarte who has written some
great explanations of computer memory.
[1] http://people.redhat.com/drepper/cpumemory.pdf
[2] http://duartes.org/gustavo/blog/
> 2009/2/14 David Sveningsson <e...@sidvind.com <mailto:e...@sidvind.com>>
> --~--~---------~--~----~------------~-------~--~----~
> Visit http://www.gowrikumar.com for good puzzles in C programming
> language and programming interview questions.
>
> You received this message because you are subscribed to the Google
> Groups "Programming Puzzles" group. To post to this group, send email to
> programmi...@googlegroups.com
> -~----------~----~----~----~------~----~------~--~---
>