Size of int and sizeof int pointer on a 64 bit machine

Viewed 91003

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.

5 Answers
Related