Arrays Boundary, Capacity and Size, CString, and Filing

Learn about what arrays are, why we need them, and how we can and cannot use arrays.

Accessing arrays

In this lesson, we will learn what happens if we access arrays out of the boundary. Also, we will learn about character arrays and how they are handled differently. Lastly, we will discuss reading data from files instead of cumbersomely initializing it on our own.

Accessing arrays out of bound

Let’s start by asking a few questions to ourselves.

What if we try to access the array index that is out of bounds for our array? What would happen if we mistakenly modify the memory indexed outside the array size?

Note that the array index can’t be negative.

See the program below as an example.

Get hands-on with 1200+ tech skills courses.