cs31day16 Wk 8 W

cs31day16 Wk 8 W - REVIEW OF OLD STUFF&x => x&a[i j =>&a[i...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
p[i] ==> *(p + i) &a[i] - &a[j] ==> i - j if one pointer is less than another, that means in smaller pointer is pointing at an address before the other void f(double a[], int n) // n tells how many things in the array to look at { ....a[k]. ... } as a parameter to a function , technically the array is a pointer, so we could write double* a instead of double a[] a[k] is the same thing as *(a + k) this points to a place k number of elements after where a points at ================================================================ ============================== what if you have two pointers and you wanted to know how far apart they were? if you have two pointers into the same array, you are allowed to subtract them . this would effectively find the number of elements in between them, or how far one is to the other. *(a + 2) - *a da[2] - da[0] 7.6 - 0.3 // this is subtracting the values that the pointers point to, not the pointer addresses ================================================================ =========================================================== int main() { double eks; ... double* dp;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

cs31day16 Wk 8 W - REVIEW OF OLD STUFF&x => x&a[i j =>&a[i...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online