New version page

# TRINITY CSCI 1320 - Arrays as Pointers

Pages: 7
Documents in this Course

14 pages

10 pages

4 pages

8 pages

16 pages

8 pages

8 pages

9 pages

12 pages

15 pages

10 pages

7 pages

15 pages

10 pages

8 pages

15 pages

9 pages

8 pages

10 pages

13 pages

10 pages

10 pages

9 pages

16 pages

11 pages

8 pages

10 pages

14 pages

13 pages

4 pages

3 pages

15 pages

14 pages

10 pages

9 pages

9 pages

10 pages

11 pages

4 pages

7 pages

11 pages

11 pages

12 pages

4 pages

11 pages

8 pages

5 pages

15 pages

9 pages

8 pages

18 pages

7 pages

6 pages

13 pages

10 pages

13 pages

14 pages

9 pages

11 pages

7 pages

9 pages

11 pages

15 pages

10 pages

4 pages

13 pages

9 pages

10 pages

13 pages

15 pages

7 pages

16 pages

9 pages

11 pages

8 pages

13 pages

15 pages

10 pages

14 pages

6 pages

11 pages

10 pages

12 pages

4 pages

13 pages

8 pages

18 pages

11 pages

10 pages

8 pages

13 pages

## This preview shows page 1-2 out of 7 pages.

View Full Document
Do you want full access? Go Premium and unlock all 7 pages.
Do you want full access? Go Premium and unlock all 7 pages.

Unformatted text preview:

1Arrays as Pointers10-26-20062Opening Discussion■What did we talk about last class?■Do you have any questions about the reading?■Do you have any questions about the assignment?■Minute essay responses.3Arrays as Pointers■I've said many times that 1-D arrays are basically just pointers. Let's explore that idea a bit to see how things are laid out in memory.■What do we get if we print the name of an array? What if we print the address of it?■What are the addresses of the various elements in an array?■What are the differences in behavior between a pointer variable and an array variable?4Using Pointer Arithmetic■I've shown you several times how we can do arithmetic on pointers. This gives you low level control to look through memory on a machine.■Pointer arithmetic behaves properly for the type of things that the pointer points to.■Let's write a loop that prints the contents of an array, but does it without ever using []. This type of code isn't really needed with modern compilers but is definitely worth understanding.5Multidimensional Arrays■What does a 2-D array look like in memory?■How is a 2-D array different from a pointer to a pointer?■Let's using some print statements to examine the structure of a 2-D array in memory and use that to compare that to the image of how a pointer to a pointer could act like a 2-D array.6Dynamic Memory■The arrays that we have dealt with have some serious limitations. Most notably, they have to have a fixed length to adhere to the C standard. Having to specify the length of everything but the first dimension in a multidimensional array is also a bit limiting.■The way we get around this in C (and many other languages) is to use dynamic memory. Dynamic memory is memory that we can request from a different part of memory. Normal arrays get placed on the call stack in the normal stack frames. Dynamic memory, including arrays, comes from the heap.7Minute Essay■Write a function that will tell you if two strings are equal. The trick is that the function can't use [].■Remember that assignment #5 is due

View Full Document