Save this video free

Lecture 22: Arrays (and pointers)

Burton Ma · 45:12 · Watch on YouTube

Part of Queen's University CISC220. See all 23 lectures and search them

These notes were made with YouTube Collector. Paste any YouTube link and get the same: a summary, chapters and a searchable transcript.

Overview

C arrays are fixed-size, contiguous sequences, and array expressions commonly convert to pointers to their first element. The lecture connects that behavior to array initialization, null-terminated strings, copying with `memcpy`, pointer arithmetic, and the bounds and comparison rules that make pointer use error-prone.

Key takeaways

Chapters

0:00 C Array Basics, Capacity, and Initialization
5:51 C Strings and the Null Terminator
11:20 Const Arrays and Why Array Assignment Fails
15:00 Using `memcpy` to Copy Array Memory
20:44 Copying Array Segments and C Strings
24:11 Array-to-Pointer Conversion and Pointer Aliasing
31:31 Pointer Arithmetic as Array Indexing
37:11 Out-of-Bounds Access and the One-Past Pointer
40:07 Comparing Pointers Within an Array

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

0:01 Right. Good morning everybody. Uh so today's lecture is about arrays. Um and in particular the relationship of pointers to arrays. So the first part of this lecture is probably review from a lecture a few either last week or yeah probably last week or the week before where I introduced the types uh in the C language. uh and then we'll move on to some new stuff. Um and we'll see how do u how uh pointers and arrays actually have a very close relationship to one another. All right. So very quickly let's review what an array is. So arrays uh in C and Java are very similar but there are important differences. Uh so in in both languages an array is a contiguous sequence of objects all

0:48 having the same type. Right? Again remember what contiguous means. This means that each object of the array is beside the previous element of the array. Uh in both languages, the capacity, so the maximum number of elements you can put into the array, never changes. Right? If you need a bigger or smaller array, you have to make a bigger or smaller array, copy the elements of the original array into the new array. uh in both languages the array uh is characterized by the type of elements that it holds. So the an array of type an array that holds ints the int is part of the array type name. Uh and then you use square brackets in both languages to access the individual elements. The important differences are uh there's no

1:35 zero length array in C. So in C an array always holds at least or the capacity of an array is always at least one. uh whereas you are allowed to have an empty array in Java, right? An array of length

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

In this course

Related notes

Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Burton Ma.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.