From 61897bcbcf57eead0ccb09ef62d9670a4f71bcd9 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Mon, 11 Sep 2023 21:44:42 -0400 Subject: [PATCH] adding the pointer arithmetic section --- lectures/04_pointers/README.md | 36 ++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/lectures/04_pointers/README.md b/lectures/04_pointers/README.md index 1afef7f..fc6e6a0 100644 --- a/lectures/04_pointers/README.md +++ b/lectures/04_pointers/README.md @@ -146,7 +146,39 @@ shrink dynamically in response to the demands of the application. - play this [animation](https://jidongxiao.github.io/CSCI1200-DataStructures/animations/pointers/example_arrays_1/index.html). -## 4.8 Sorting an Array +## 4.8 Stepping through Arrays with Pointers (Array Iterators) + +- The array code above that uses [] subscripting, can be equivalently rewritten to use pointers: +```cpp +const int n = 10; +double a[n]; +double *p; +for ( p=a; p