Home Segments Index Top Previous Next

537: Mainline

The reason strings are terminated by null characters is that 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 output operator, <<, relies on null characters when it deals with strings.