• Use the typedef to define a new type named ‘letters’ that includes all the alphabetic letters. Define a boolean array of size 26 to represent the set. So, for example, the set, {‘a’, ‘b’ , ‘c’} will be represented as follows, letterArray, T T T F F F F F F F F F F F F F F F F F F F F F F F a b c d e f g h i j k l m n o p q r s t u v w x y z For each letter, if letterArray[letter]==TRUE then letter belongs to the group and if its FALSE it means that letter does not belong to the group. • Note that typedef’s when used in input and output operations are considered as integers and not as characters (letters). Thus, if you want to write a procedure disp that displays the letters of the set to the output, the following version would not work – void disp (bool set[size]) /* This would NOT work!!! */ { letters l; for (l=a; l<=z; l++) { if (set[l]) printf (“\t%c”,l); } } Instead you should “convert” the integer that represents each letter of the letters typedef, to the corresponding character, using the ASCII table shown earlier. So the correct version of disp will look like this, void disp (bool set[size]) /* The correct version */ { letters l; for (l=a; l<=z; l++) { if (set[l]) printf (“\t%c”,l+97); } } /* The value of the variable l is in the range of 0-25 since it is defined as an instance of the letters typedef. Adding 97 to l will return the ASCII code of the corresponding lower case letter). */ |
|
|
|
|
init(set)
i was just told to initialize the sets A and B accordingly within the program. and i think i do see the idea.
init(set)
is supposed to give values to A and B. but how would i do this? Please help.
oh i think the init(set) is supposed to give values to A and B |
|
|
too few arguments to function `char unions(char, char, char)' |
|
|
|
|