I am wondering why in the following program sizeof(int)
returns a different value than sizeof(int*)
.
Here is the small program:
int main(){
std::cout<<sizeof(int)<<endl;
std::cout<<sizeof(int*)<<endl;
return 0;
}
And here is the output:
4
8
Till now I remember the size of a integer pointer is 4byte(gcc compiler). How can I check the correct size of a pointer? Is it computer dependent?
I am running ubuntu 12.04
# lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 12.04 LTS
Release: 12.04
Codename: precise
Is the size of pointer is not constant(standard size) 8 bytes.