Previous Lecture lect09 Next Lecture

lect09, Thu 02/07

Arrays and Makefile

Recap from last time: reading from a file

Lecture material

Arrays in C++

Syntax

More on memory

What if I go out of bounds of an array?

  • Bad things may happen. You might corrupt your data, mess with other variables, or could potentially hit a segfault (i.e., segmentation fault) if you go out of bounds of memory allocated by the OS for your program.
    • If the size of your array is 10, the last element you should reach is a[9].
    • a[10] points to a memory location that is not within the array!
    • the index of the last element of the array is at (size - 1).

Arrays in functions

Makefiles & header files

Update: Take a look at the Makefile Walkthrough that we posted on Piazza https://piazza.com/class/jqm50idtsek4wz?cid=177 for additional explanation.

Header files

Notes