Sams Teach Yourself C in 21 Days

(singke) #1
Answers 869

F


6.strcmp()compares two strings, considering the case of the letters. (For example,
‘A’and‘a’are different.) strcmpi()ignores case. (For example,‘A’and‘a’are
the same.)
7.isascii()checks the value passed to see whether it’s a standard ASCII character
between 0 and 127. It doesn’t check for extended ASCII characters.
8.isascii()andiscntrl()both return TRUE; all others return FALSE. Remember,
these macros look at the character value.


  1. 65 is equivalent to the ASCII character A. The following macros return TRUE:isal-
    num(),isalpha(),isascii(),isgraph(),isprint(), andisupper().

  2. The character-test functions determine whether a particular character meets a cer-
    tain condition, such as whether it is a letter, punctuation mark, or something else.


Exercises

1.TRUE(1) or FALSE(0)


  1. a. 65
    b. 81
    c. –34
    d. 0
    e. 12
    f. 0

  2. a. 65.000000
    b. 81.230000
    c. –34.200000
    d. 0.000000
    e. 12.000000
    f. 1000.000000
    4.string2wasn’t allocated space before it was used. There is no way to know where
    strcpy()copies the value of string1.


Answers for Day 18

Quiz


  1. Passing by value means that the function receives a copy of the value of the argu-
    ment variable. Passing by reference means that the function receives the address of
    the argument variable. The difference is that passing by reference allows the func-
    tion to modify the original variable, whereas passing by value does not.


49 448201x-APP F 8/13/02 11:22 AM Page 869

Free download pdf