I was just wondering how can I know if my laptop is 64 or 32 bit machine. (it is a 64).
So, I thought about printing the following:
int main()
{
printf("%d",sizeof(int));
}
and the result was 4, which seemed weird (since it is a 64 bit machine)
But, when I printed this:
int main()
{
printf("%d",sizeof(int*));
}
the result was 8, which made more sense.
The question is:
Since I'm using a 64 bit machine, shouldn't a primitive type such as int should use 8 bytes
(64 bit) and by that sizeof int should be 8? Why isn't it so?
And why is the int* size is 8?
A bit confused here,
so thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…