I have unexpected outcome with sizeof operator (C++). In main class, I have these lines
double * arguments_ = new double();
*arguments_ = 2.1;
*(arguments_+1) = 3.45;
cout << (sizeof arguments_) << ' ' << (sizeof arguments_[0]) << ' '<< (sizeof arguments_)/(sizeof arguments_[0]);
which give me output 4 8 0
Double size is 8 bytes, and (sizeof arguments_[0]) = 8. However, why is (sizeof arguments_) not expressed in bytes as well (2*8 = 16)? Is sizeof operator applica
Both values are expressed in the same units. You have a 32-bit system, so the size of an address is 32 bits, or 4 bytes. The size of double on your system is 8 bytes. The result of an integer division 4/8
is zero.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With