A concordance of a text is a listing of every string that occurs in the text along with the locations of that string. Here's an example run of such a program.
$ concordance This program produces a word concordance for text you enter. Please enter the text. Finish with ad character. Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, `and what is the use of a book,' thought Alice `without pictures or conversation?' So she was considering in her own mind (as well as she could, for the hot day made her feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her. Here is the concordance for your text. a 50 87 104 alice 1 53 and 16 44 80 98 as 66 68 bank 15 be 91 beginning 3 book 30 51 but 35 by 10 112 chain 89 close 111 considering 61 conversation 57 conversations 41 could 70 daisies 101 daisy 88 day 74 do 21 eyes 109 feel 77 for 71 get 5 getting 96 had 26 37 having 18 her 11 31 63 76 113 hot 73 in 42 62 into 28 is 46 it 36 43 made 75 making 86 mind 65 no 38 nothing 19 of 8 17 49 85 95 on 13 once 22 or 23 40 56 own 64 peeped 27 picking 99 pictures 39 55 pink 108 pleasure 84 rabbit 106 ran 110 reading 34 she 25 59 69 sister 12 32 sitting 9 sleepy 79 so 58 stupid 81 suddenly 103 the 14 29 47 72 83 93 100 thought 52 tired 7 to 4 20 trouble 94 twice 24 up 97 use 48 very 6 78 was 2 33 60 well 67 what 45 when 102 whether 82 white 105 with 107 without 54 worth 92 would 90
This program lists the occurances of each word. For instance, the word "and" occurs four times in the textat word number 16, word number 44 word number 80, and word number 98.
Your assignment is to create, test, and run such a program. Turn in a printout of the source code and of a test run of your program with the Alice text or anything else you like of approximately the same length and complexity.
You may start your program from scratch, or you may use the partially written code at concordance.c which refers to the header file concordance.h. It has function stubs for the important functions; you'll have to fill them in.
Back to the course page.