August 1996
Intermediate to advanced
544 pages
9h 33m
English
C is not a string-processing language per se, but it does include facilities for manipulating arrays of characters, which are commonly called strings. By convention, an N-character string is an array of N+1 characters in which the last character is the null character; that is, it has the value zero.
The language itself has only two features that help process strings. Pointers to characters can be used to traverse character arrays, and string literals can be used to initialize arrays of characters. For example,
char msg[] = "File not found";
is shorthand for
char msg[] = { 'F', 'i', 'l', 'e', ' ', 'n', 'o', 't',
' ', 'f', 'o', 'u', 'n', 'd', '\0' };Incidentally, character constants, like 'F', are ints, not chars, which ...
Read now
Unlock full access