diff options
Diffstat (limited to '4p29.cpp')
-rw-r--r-- | 4p29.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/4p29.cpp b/4p29.cpp new file mode 100644 index 0000000..44a0245 --- /dev/null +++ b/4p29.cpp @@ -0,0 +1,20 @@ +#include <iostream> + +/* + * + * 4.29 + * + * + */ + +int main () { + + int x[10]; + int *p = x; + auto xx = sizeof(x) / sizeof(*x); + auto pp1 = sizeof(p); + auto pp2 = sizeof(*p); + std::cout << xx << std::endl; // int is 32bit on my machine therefore 40 / 4 = 10 + std::cout << pp1 / pp2 << std::endl; // we get the size of a pointer(8) then the size of an int(4) = 2 + return 0; +} |