From 17dc203b20852b03ec225bb2ca45ed87fd44175d Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Mon, 11 Sep 2023 22:58:46 -0400 Subject: [PATCH] adding second approach to the pointer arithmetic example --- lectures/04_pointers/README.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lectures/04_pointers/README.md b/lectures/04_pointers/README.md index 8aeea9c..25bdda6 100644 --- a/lectures/04_pointers/README.md +++ b/lectures/04_pointers/README.md @@ -148,13 +148,16 @@ shrink dynamically in response to the demands of the application. ## 4.8 Stepping through Arrays with Pointers (Array Iterators) -- The array code above that uses [] subscripting, can be equivalently rewritten to use pointers: +- The array code above that uses [] subscripting, can be equivalently rewritten to use pointers. We can re-write it in two ways: + +### 4.8.1 First Approach + ```cpp const int n = 10; double a[n]; double *p; for ( p=a; p