Home Segments Index Top Previous Next

495: Mainline

Strings are terminated by null characters because string-manipulation functions—both those that are built in and those you may choose to define—generally have no way to know, in advance, how many characters there are in any given string. Those functions rely, instead, on null characters—serving as end-of-string markers—to tell them when to stop as they work their way through the characters.

In particular, the display function, printf, relies on null characters when it displays strings.