Small code snippets in C.
#include<stdio.h>
int main()
{
printf("%zu\n%zu\n", sizeof(char*), sizeof(double*));
}
Output:(GCC 64 bit)
8
8
Is sizeof(char*)
always equal to sizeof(double*)
?
What C standard say about this?
Small code snippets in C.
#include<stdio.h>
int main()
{
printf("%zu\n%zu\n", sizeof(char*), sizeof(double*));
}
Output:(GCC 64 bit)
8
8
Is sizeof(char*)
always equal to sizeof(double*)
?
What C standard say about this?
Both, sizeof(char*)
and sizeof(double*)
are the size of a pointer. So they are very likely identical on any imaginable system.
It is however theoretically possible that an implementation has different methods for referencing different datatypes. I could imagine a system wiht a small size optimisation memory scheme doing e.g. single byte plain old data in a special place with implicitly "only" 32 bit pointers, while it does larger compound constructs in a larger area, which needs 64 bit pointers.
So there is no guarantee of this seemingly "obvious" assumption.
This does of course assume that everything is on the same system, pointer sizes can and do vary between different systems.
not only this whenever you print a pointer variable you will get the same value. Because pointer variable is used to hold the address of the variable.