Demo: Visit Each Character
Inspect each letter on a sign
To print a numbered list of a sign's letters, start at index 0 and keep going until the character there is \0. That terminator is a stopping marker, not another letter to print. This loop relies on the array containing a terminator before its end; without one, it would keep reading past the array.
c
#include <stdio.h>
int main(void) {
char label[] = "OK";
for (size_t i = 0; label[i] != '\0'; i++) {
printf("%zu: %c\n", i, label[i]);
}
return 0;
}
Run and note indexes 0 and 1. Change the label to "OPEN" and count its visible characters. A character array without a terminator is not safe for this pattern. The same loop shape can count a particular letter instead of printing each one.