Sams Teach Yourself C in 21 Days

(singke) #1
Answers 867

F



  1. a.zis an array of 10 pointers to characters.
    b.yis a function that takes an integer (field) as an argument and returns a
    pointer to a character.
    c.xis a pointer to a function that takes an integer (field) as an argument and
    returns a character.


Exercises

1.float (*func)(int field);
2.int (*menu_option[10])(char *title);
An array of function pointers can be used in conjunction with a menuing system.
The number selected from a menu could correspond to the array index for the
function pointer. For example, the function pointed to by the fifth element of the
array would be executed if item 5 were selected from the menu.
3.char *ptrs[10];
4.ptris declared as an array of 12 pointers to integers, not a pointer to an array of 12
integers. The correct code is
int x[3][12];
int (*ptr)[12];
ptr = x;


  1. The following is one of many possible solutions:
    struct friend {
    char name[35+1];
    char street1[30+1];
    char street2[30+1];
    char city[15+1];
    char state[2+1];
    char zipcode[9+1];
    struct friend *next;
    }


Answers for Day 16

Quiz


  1. A text-mode stream automatically performs translation between the newline char-
    acter (\n), which C uses to mark the end of a line, and the carriage-return linefeed
    character pair that DOS uses to mark the end of a line. In contrast, a binary-mode
    stream performs no translations. All bytes are input and output without modifica-
    tion.


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

Free download pdf