New version page

TRINITY CSCI 1320 - Arrays as Pointers

Documents in this Course
Functions

Functions

10 pages

Functions

Functions

10 pages

Graphics

Graphics

10 pages

Graphics

Graphics

11 pages

Loops

Loops

4 pages

Loops

Loops

3 pages

Strings

Strings

9 pages

Functions

Functions

10 pages

Loops

Loops

11 pages

Graphics

Graphics

11 pages

Graphics

Graphics

12 pages

Sorting

Sorting

11 pages

Sorting

Sorting

10 pages

Arrays

Arrays

10 pages

Loops

Loops

18 pages

Load more
Upgrade to remove ads

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

Save
View Full Document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Upgrade to remove ads
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
Download Arrays as Pointers
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Arrays as Pointers and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Arrays as Pointers 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?