From 4c8377e5711e2c864c8754d1d6373c09da2ce7e1 Mon Sep 17 00:00:00 2001 From: Oskar Date: Wed, 21 Aug 2024 20:55:10 +0200 Subject: more exercises --- 4p29.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 4p29.cpp (limited to '4p29.cpp') 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 + +/* + * + * 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; +} -- cgit v1.2.3