Answers to Chapter 14 Review Questions -------------------------------------- 1. As arrays of characters, as pointers to characters, and as abstract units. 2. C stores a null character ('\0') after the last data character to mark the end. 3. The following code processes the characters in a string treated as an array: for (i=0; str[i]!='\0'; i++) { ... body of the loop that manipulates str[i] ... } If instead the string is viewed as a pointer to a character, the following code as the same effect: for (cp=str; *cp!='\0'; cp++) { ... body of loop that manipulates *cp ... } 4. True, because the space for the string has already been set aside by the caller. 5. False, because declaring a local variable as a character array reserves space for the characters, while declaring is as pointer does not allocate any space beyond what is needed to hold the address. 6. Arrays cannot appear on the left side of an assignment and cannot be returned as the value of a function. 7. The storage of a local array is deallocated when the function declaring it returns. If you return a pointer to that array, the caller then has a pointer to memory that is no longer available for use. 9. In the function call strcpy(s1, s2), s2 is the source and s1 is the destination. 10.As with any function in the ANSI string.h interface, you must ensure that there is enough allocated memory in the destination string to hold the entire result. 11.Buffer overflow occurs when a program writes data past the end of an array. 13.The test strcmp(s1, s2) == 0 is how to determine if two strings are equal.