Save this video free

Lecture 16: Types

Burton Ma · 45:58 · Watch on YouTube

Part of Queen's University CISC220. See all 15 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.

Lecture 16: Types Watch on YouTube →

Overview

Burton Ma compares C types with Java and Python, focusing on how C handles `const`, arrays, strings, and structs. He emphasizes practical hazards such as unchecked array indexes, `sizeof` returning pointer size for array parameters, and the need to reserve space for a string’s null terminator.

Key takeaways

Chapters

0:00 C `const`, Math Library Linking, and `void`
6:57 C Array Types, Fixed Sizes, and Unchecked Indexes
11:09 Array Initialization and Initializer Lists
16:02 `sizeof` Measures Array Memory, Not a Reliable Length
19:49 Out-of-Bounds Writes and C Undefined Behavior
25:41 C Strings Use Character Arrays and Null Terminators
30:21 Concatenating C Strings and Allocating Enough Space
36:13 Missing String Terminators Cause Out-of-Bounds Reads
39:09 C `struct` Types and Member-by-Member Data

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

Transcript excerpt

0:02 Okay, good afternoon everybody. So, we're going to continue from where we left off in the last class. Uh so, we're in the types notebook of the C part of the course. Uh we just finished talking about floating point numbers. There's nothing special about floating point numbers. They behave exactly the same in C as they do in Java. Um so, the next thing I want to tell you about is uh this keyword called const. Uh so, you can declare a variable to be const, uh which makes the variable unassignable. Uh so, remember in the last class I made an effort to distinguish between assignment versus initialization. Uh so, this says if you make a variable that's const, you can't assign to the variable. Uh and so, that means you probably almost certainly want to initialize the variable. Um basically, what that means is

0:49 you end up with a value that can never change, uh which is useful for some things, right? So, for example, if you're defining the value of pi, uh it probably makes sense to declare it const. This is almost but not exactly the same as final in Java. Uh so, in Java, uh final means you can only assign to the variable once. It doesn't mean you have to initialize it, though. Uh so, Oops, sorry. There's a little Java program that declares a final variable called X. It hasn't been initialized yet. Um and it hasn't been given a value yet. Uh final means you can give it a value exactly once. So, on the next line or somewhere later in the program, you can

1:36 write X equals 1, and that's fine. You've given X a value exactly once. Uh and this works just fine. So, if you compile it with the Java compiler,

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.