From 456ce2efc1a2f14cdaa853ec9a95945a77ff2a08 Mon Sep 17 00:00:00 2001 From: Oskar Date: Thu, 22 Aug 2024 19:21:59 +0200 Subject: more --- 4p32.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 4p32.cpp (limited to '4p32.cpp') diff --git a/4p32.cpp b/4p32.cpp new file mode 100644 index 0000000..346b82e --- /dev/null +++ b/4p32.cpp @@ -0,0 +1,23 @@ +#include + +/* + * + * 4.32 + * + * We have a pointer thats basically like a begin() iterator + * We have ix that starts at 0 + * We keep looping as long as ix is not equal to the size + * We keep looping as long as ptr does not point to one past the last element in ia + * This ensures that we can safely do stuff to the array inside the loop + */ + +int main () { + + constexpr int size = 5; + int ia[size] = {1,2,3,4,5}; + for (int *ptr = ia, ix = 0 ; ix != size && ptr != ia+size ; ++ix, ++ptr){ + /* . . . */ + } + + return 0; +} -- cgit v1.2.3