Save this video free

Lecture 24: Strings

Burton Ma · 48:19 · 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

Burton Ma explains how C represents strings as character arrays terminated by a null character, then uses string.h functions to teach the relationship between arrays, pointers, and memory safety. Examples cover string length, copying, and concatenation, including why undersized buffers, missing terminators, and overlapping source and destination strings can cause undefined behavior.

Key takeaways

Chapters

0:00 C Strings, Null Terminators, and Character Encodings
5:00 Missing Terminators Cause Overreads and Buffer Overruns
10:00 Multiple Strings in One Array and String Literal Sizes
15:00 String Literal Storage and Read-Only Character Data
19:00 strlen Counts Characters Before the First Null
23:00 Implementing strlen with Array Indexes and Pointers
32:00 strcpy Copies a Terminated String into a Destination Buffer
38:30 strcpy Pointer Loops and Overlap Restrictions
43:50 strcat Appends Strings and Requires Sufficient Capacity

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

Transcript excerpt

0:00 Okay. Good afternoon, everybody. So, we're in the strings notebook now. And this is also the topic of the assignment that was posted last night. So, useful lecture to be attending. So, quickly remind you what a string is. So, in C, a string is just a car array where the end of the string is marked by a character called the null terminator. So, remember the null terminator, its numeric value is zero, but its character would be backslash zero. So, the language provides very few functions to support strings. There's the usual ones that you would expect. But if you look at if you compare C

0:47 support for strings to something like Python or Java, C's support for strings is very primitive. So, there aren't very many functions that you need to know about. If you want to use one of these functions, they're probably in string.h. Now, that particular header file uses most of the functions there involve arrays of car. Now, car is typically an 8-bit type on most modern computing architectures. So, 8 bits means you have 255 different characters, which isn't very many. 256, sorry, different characters, which is fine for a language like English. But for, say, the Asian many of the Asian languages which have thousands of characters in them,

1:35 these sorts of functions don't work well with those types of languages. So, if you're poking around the the documentation for the C language, you might come across wcar_t. So, that's a wide character type. So, a wide character type is either 16 or 32 bits. And so, that can support many, many more characters. We're only using the the English characters. So, we we stick with char. Um so, even though there are a lot of these functions have support for these

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.