Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

1Learning Outcomes

No video.

2C Strings vs. char arrays

A C string is just an array of characters, followed by a null terminator. A null terminator is the byte of all 0’s, i.e., the ‘\0’ character.

The null terminator lets us determine the length of a C string from just a pointer to the beginning of the string. Consider the following code, which is a reasonable implementation of strlen, the standard C library function that computes the length of a string, minus the null terminator.

1
2
3
4
5
int strlen(char s[]) {
    size_t n = 0; 
    while (*(s++) != 0) { n++; } 
    return n;
}