home *** CD-ROM | disk | FTP | other *** search
MacBinary | 1995-10-24 | 7.0 KB | [TEXT/CWIE] |
open in:
MacOS 8.1
|
Win98
|
DOS
view JSON data
|
view as text
This file was processed as: MacBinary
(archive/macBinary).
You can browse this item here: Choose.c
Confidence | Program | Detection | Match Type | Support
|
---|
66%
| dexvert
| Compact Compressed (Unix) (archive/compact)
| ext
| Supported |
10%
| dexvert
| MacBinary (archive/macBinary)
| fallback
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| MacBinary II, inited, Tue Oct 24 11:09:28 1995, modified Tue Oct 24 11:09:28 1995, creator 'CWIE', type ASCII, 6361 bytes "Choose.c" , at 0x1959 548 bytes resource
| default (weak)
| |
99%
| file
| data
| default
| |
74%
| TrID
| Macintosh plain text (MacBinary)
| default
| |
25%
| TrID
| MacBinary 2
| default (weak)
| |
100%
| siegfried
| fmt/1762 MacBinary (II)
| default
| |
100%
| lsar
| MacBinary
| default
|
|
id metadata |
---|
key | value |
---|
macFileType | [TEXT] |
macFileCreator | [CWIE] |
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 08 43 68 6f 6f 73 65 | 2e 63 00 00 00 00 00 00 |..Choose|.c......|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 43 57 49 | 45 01 00 00 00 00 00 00 |.TEXTCWI|E.......|
|00000050| 00 00 00 00 00 18 d9 00 | 00 02 24 ac b2 b2 28 ac |........|..$...(.|
|00000060| b2 b2 28 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |..(.....|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 c2 09 00 00 |........|........|
|00000080| 2f 2a 0d 43 68 6f 6f 73 | 65 2e 63 0d 0d 43 68 6f |/*.Choos|e.c..Cho|
|00000090| 6f 73 65 28 29 20 75 73 | 65 73 20 74 68 65 20 63 |ose() us|es the c|
|000000a0| 6f 6e 73 6f 6c 65 20 74 | 6f 20 61 73 6b 20 74 68 |onsole t|o ask th|
|000000b0| 65 20 75 73 65 72 20 61 | 20 6d 75 6c 74 69 70 6c |e user a| multipl|
|000000c0| 65 20 63 68 6f 69 63 65 | 20 71 75 65 73 74 69 6f |e choice| questio|
|000000d0| 6e 20 61 6e 64 20 61 63 | 63 65 70 74 0d 61 20 74 |n and ac|cept.a t|
|000000e0| 79 70 65 64 20 61 6e 73 | 77 65 72 2e 20 49 74 20 |yped ans|wer. It |
|000000f0| 6d 69 6e 69 6d 69 7a 65 | 73 20 74 68 65 20 6e 75 |minimize|s the nu|
|00000100| 6d 62 65 72 20 6f 66 20 | 6b 65 79 73 74 72 6f 6b |mber of |keystrok|
|00000110| 65 73 20 74 68 65 20 75 | 73 65 72 20 68 61 73 20 |es the u|ser has |
|00000120| 74 6f 20 74 79 70 65 2e | 20 54 68 65 0d 75 73 65 |to type.| The.use|
|00000130| 72 20 63 61 6e 20 73 65 | 6c 65 63 74 20 74 68 65 |r can se|lect the|
|00000140| 20 64 65 66 61 75 6c 74 | 20 61 6e 73 77 65 72 20 | default| answer |
|00000150| 62 79 20 6a 75 73 74 20 | 68 69 74 74 69 6e 67 20 |by just |hitting |
|00000160| 3c 63 72 3e 2c 20 6f 72 | 20 63 61 6e 20 73 65 6c |<cr>, or| can sel|
|00000170| 65 63 74 20 61 6e 79 20 | 6f 66 0d 74 68 65 20 63 |ect any |of.the c|
|00000180| 68 6f 69 63 65 73 20 62 | 79 20 74 79 70 69 6e 67 |hoices b|y typing|
|00000190| 20 6a 75 73 74 20 65 6e | 6f 75 67 68 20 63 68 61 | just en|ough cha|
|000001a0| 72 61 63 74 65 72 73 20 | 28 74 79 70 69 63 61 6c |racters |(typical|
|000001b0| 6c 79 20 6a 75 73 74 20 | 6f 6e 65 29 20 74 6f 20 |ly just |one) to |
|000001c0| 6d 61 6b 65 20 61 6e 0d | 75 6e 61 6d 62 69 67 69 |make an.|unambigi|
|000001d0| 6f 75 73 20 73 65 6c 65 | 63 74 69 6f 6e 2e 20 43 |ous sele|ction. C|
|000001e0| 68 6f 6f 73 65 28 29 20 | 61 75 74 6f 6d 61 74 69 |hoose() |automati|
|000001f0| 63 61 6c 6c 79 20 73 70 | 65 6c 6c 73 20 6f 75 74 |cally sp|ells out|
|00000200| 20 74 68 65 20 72 65 73 | 74 20 6f 66 20 74 68 65 | the res|t of the|
|00000210| 20 63 68 6f 69 63 65 2e | 0d 54 68 65 20 75 73 65 | choice.|.The use|
|00000220| 72 20 44 4f 45 53 20 4e | 4f 54 20 68 61 76 65 20 |r DOES N|OT have |
|00000230| 74 6f 20 74 65 72 6d 69 | 6e 61 74 65 20 74 68 65 |to termi|nate the|
|00000240| 20 61 6e 73 77 65 72 20 | 77 69 74 68 20 61 20 72 | answer |with a r|
|00000250| 65 74 75 72 6e 2e 20 54 | 68 69 73 20 6d 61 6b 65 |eturn. T|his make|
|00000260| 73 20 69 74 0d 66 65 61 | 73 69 62 6c 65 20 74 6f |s it.fea|sible to|
|00000270| 20 61 73 6b 20 74 68 65 | 20 75 73 65 72 20 61 20 | ask the| user a |
|00000280| 6c 6f 6e 67 20 73 65 72 | 69 65 73 20 6f 66 20 6d |long ser|ies of m|
|00000290| 75 6c 74 69 70 6c 65 2d | 63 68 6f 69 63 65 20 71 |ultiple-|choice q|
|000002a0| 75 65 73 74 69 6f 6e 73 | 2c 20 73 69 6e 63 65 20 |uestions|, since |
|000002b0| 74 68 65 0d 75 73 65 72 | 20 63 61 6e 20 71 75 69 |the.user| can qui|
|000002c0| 63 6b 6c 79 20 68 69 74 | 20 72 65 74 75 72 6e 20 |ckly hit| return |
|000002d0| 74 6f 20 6f 62 74 61 69 | 6e 20 64 65 66 61 75 6c |to obtai|n defaul|
|000002e0| 74 20 61 6e 73 77 65 72 | 73 20 61 6e 64 20 6e 65 |t answer|s and ne|
|000002f0| 65 64 20 6f 6e 6c 79 20 | 74 79 70 65 20 6f 6e 65 |ed only |type one|
|00000300| 20 28 6f 72 0d 61 20 66 | 65 77 29 20 63 68 61 72 | (or.a f|ew) char|
|00000310| 61 63 74 65 72 73 20 74 | 6f 20 73 65 6c 65 63 74 |acters t|o select|
|00000320| 20 6e 6f 6e 2d 64 65 66 | 61 75 6c 74 20 63 68 6f | non-def|ault cho|
|00000330| 69 63 65 73 2e 0d 0d 09 | 69 6e 74 20 43 68 6f 6f |ices....|int Choo|
|00000340| 73 65 28 69 6e 74 20 64 | 65 66 61 75 6c 74 43 68 |se(int d|efaultCh|
|00000350| 6f 69 63 65 2c 63 6f 6e | 73 74 20 63 68 61 72 20 |oice,con|st char |
|00000360| 2a 71 75 65 72 79 2c 63 | 6f 6e 73 74 20 63 68 61 |*query,c|onst cha|
|00000370| 72 20 2a 63 68 6f 69 63 | 65 73 5b 5d 2c 69 6e 74 |r *choic|es[],int|
|00000380| 20 6e 29 3b 0d 0d 09 63 | 68 6f 69 63 65 3d 43 68 | n);...c|hoice=Ch|
|00000390| 6f 6f 73 65 28 63 68 6f | 69 63 65 2c 22 57 69 6c |oose(cho|ice,"Wil|
|000003a0| 6c 20 79 6f 75 20 65 61 | 74 20 25 73 3f 5c 6e 22 |l you ea|t %s?\n"|
|000003b0| 2c 62 72 65 61 64 46 69 | 73 68 2c 32 29 3b 0d 0d |,breadFi|sh,2);..|
|000003c0| 54 68 65 20 66 69 72 73 | 74 20 61 72 67 75 6d 65 |The firs|t argume|
|000003d0| 6e 74 20 61 6e 64 20 72 | 65 74 75 72 6e 65 64 20 |nt and r|eturned |
|000003e0| 76 61 6c 75 65 20 61 72 | 65 20 69 6e 74 2c 20 77 |value ar|e int, w|
|000003f0| 69 74 68 20 76 61 6c 75 | 65 73 20 69 6e 20 74 68 |ith valu|es in th|
|00000400| 65 20 72 61 6e 67 65 20 | 30 20 74 6f 0d 6e 2d 31 |e range |0 to.n-1|
|00000410| 2c 20 77 68 65 72 65 20 | 6e 20 28 74 68 65 20 6c |, where |n (the l|
|00000420| 61 73 74 20 61 72 67 75 | 6d 65 6e 74 29 20 69 73 |ast argu|ment) is|
|00000430| 20 74 68 65 20 6e 75 6d | 62 65 72 20 6f 66 20 70 | the num|ber of p|
|00000440| 6f 73 73 69 62 6c 65 20 | 63 68 6f 69 63 65 73 2e |ossible |choices.|
|00000450| 20 54 68 65 0d 73 65 63 | 6f 6e 64 20 61 72 67 75 | The.sec|ond argu|
|00000460| 6d 65 6e 74 20 69 73 20 | 61 20 66 6f 72 6d 61 74 |ment is |a format|
|00000470| 20 73 74 72 69 6e 67 20 | 74 6f 20 62 65 20 75 73 | string |to be us|
|00000480| 65 64 20 20 28 77 69 74 | 68 6f 75 74 20 74 68 65 |ed (wit|hout the|
|00000490| 20 6f 70 74 69 6f 6e 61 | 6c 20 74 72 61 69 6c 69 | optiona|l traili|
|000004a0| 6e 67 0d 5c 6e 29 20 69 | 6e 20 61 20 70 72 69 6e |ng.\n) i|n a prin|
|000004b0| 74 66 20 73 74 61 74 65 | 6d 65 6e 74 2e 20 54 68 |tf state|ment. Th|
|000004c0| 65 20 6f 70 74 69 6f 6e | 61 6c 20 25 73 20 77 69 |e option|al %s wi|
|000004d0| 6c 6c 20 62 65 20 65 78 | 70 61 6e 64 65 64 20 69 |ll be ex|panded i|
|000004e0| 6e 74 6f 20 61 20 6c 69 | 73 74 20 6f 66 0d 61 6c |nto a li|st of.al|
|000004f0| 74 65 72 6e 61 74 69 76 | 65 73 20 61 70 70 72 6f |ternativ|es appro|
|00000500| 70 72 69 61 74 65 6c 79 | 20 70 75 6e 63 74 75 61 |priately| punctua|
|00000510| 74 65 64 20 62 79 20 63 | 6f 6d 6d 61 73 20 61 6e |ted by c|ommas an|
|00000520| 64 20 22 6f 72 22 2e 20 | 54 68 65 20 74 68 69 72 |d "or". |The thir|
|00000530| 64 20 61 72 67 75 6d 65 | 6e 74 20 69 73 0d 61 6e |d argume|nt is.an|
|00000540| 20 61 72 72 61 79 20 6f | 66 20 6e 20 73 74 72 69 | array o|f n stri|
|00000550| 6e 67 20 70 6f 69 6e 74 | 65 72 73 2c 20 6f 6e 65 |ng point|ers, one|
|00000560| 20 73 74 72 69 6e 67 20 | 70 65 72 20 63 68 6f 69 | string |per choi|
|00000570| 63 65 2e 20 49 66 20 74 | 68 65 20 73 65 63 6f 6e |ce. If t|he secon|
|00000580| 64 20 61 72 67 75 6d 65 | 6e 74 0d 65 6e 64 73 20 |d argume|nt.ends |
|00000590| 69 6e 20 5c 6e 20 74 68 | 65 6e 20 74 68 65 20 70 |in \n th|en the p|
|000005a0| 72 69 6e 74 69 6e 67 20 | 6f 66 20 74 68 61 74 20 |rinting |of that |
|000005b0| 6e 65 77 6c 69 6e 65 20 | 63 68 61 72 61 63 74 65 |newline |characte|
|000005c0| 72 20 69 73 20 64 65 6c | 61 79 65 64 20 75 6e 74 |r is del|ayed unt|
|000005d0| 69 6c 20 41 46 54 45 52 | 20 70 72 69 6e 74 69 6e |il AFTER| printin|
|000005e0| 67 0d 74 68 65 20 75 73 | 65 72 27 73 20 63 68 6f |g.the us|er's cho|
|000005f0| 69 63 65 2e 0d 0d 54 68 | 65 20 6f 74 68 65 72 20 |ice...Th|e other |
|00000600| 72 6f 75 74 69 6e 65 73 | 20 69 6e 20 74 68 69 73 |routines| in this|
|00000610| 20 66 69 6c 65 2c 20 4d | 75 6c 74 69 70 6c 65 43 | file, M|ultipleC|
|00000620| 68 6f 69 63 65 28 29 20 | 61 6e 64 20 59 65 73 4f |hoice() |and YesO|
|00000630| 72 4e 6f 28 29 20 61 72 | 65 20 6f 62 73 6f 6c 65 |rNo() ar|e obsole|
|00000640| 74 65 2c 0d 73 69 6e 63 | 65 20 43 68 6f 6f 73 65 |te,.sinc|e Choose|
|00000650| 28 29 20 69 73 20 6d 6f | 72 65 20 63 6f 6e 76 65 |() is mo|re conve|
|00000660| 6e 69 65 6e 74 2c 20 62 | 75 74 20 74 68 65 79 20 |nient, b|ut they |
|00000670| 61 72 65 20 72 65 74 61 | 69 6e 65 64 20 66 6f 72 |are reta|ined for|
|00000680| 20 73 75 70 70 6f 72 74 | 20 6f 66 20 6f 6c 64 0d | support| of old.|
|00000690| 70 72 6f 67 72 61 6d 73 | 20 74 68 61 74 20 6d 61 |programs| that ma|
|000006a0| 79 20 75 73 65 20 74 68 | 65 6d 2e 20 43 68 6f 6f |y use th|em. Choo|
|000006b0| 73 65 20 69 73 20 69 6d | 70 6c 65 6d 65 6e 74 65 |se is im|plemente|
|000006c0| 64 20 62 79 20 63 61 6c | 6c 69 6e 67 20 4d 75 6c |d by cal|ling Mul|
|000006d0| 74 69 70 6c 65 43 68 6f | 69 63 65 2e 0d 0d 4d 75 |tipleCho|ice...Mu|
|000006e0| 6c 74 69 70 6c 65 43 68 | 6f 69 63 65 28 29 20 61 |ltipleCh|oice() a|
|000006f0| 63 63 65 70 74 73 20 28 | 61 6e 64 20 65 63 68 6f |ccepts (|and echo|
|00000700| 65 73 20 6f 6e 20 74 68 | 65 20 63 6f 6e 73 6f 6c |es on th|e consol|
|00000710| 65 29 20 61 20 70 61 72 | 74 69 61 6c 20 74 79 70 |e) a par|tial typ|
|00000720| 65 64 20 72 65 73 70 6f | 6e 73 65 20 74 6f 0d 61 |ed respo|nse to.a|
|00000730| 20 6d 75 6c 74 69 70 6c | 65 2d 63 68 6f 69 63 65 | multipl|e-choice|
|00000740| 20 71 75 65 73 74 69 6f | 6e 2c 20 65 78 70 61 6e | questio|n, expan|
|00000750| 64 69 6e 67 20 74 68 65 | 20 72 65 73 70 6f 6e 73 |ding the| respons|
|00000760| 65 20 74 6f 20 70 72 69 | 6e 74 20 74 68 65 20 66 |e to pri|nt the f|
|00000770| 75 6c 6c 20 61 6e 73 77 | 65 72 20 74 68 61 74 0d |ull answ|er that.|
|00000780| 69 74 20 75 6e 69 71 75 | 65 6c 79 20 73 70 65 63 |it uniqu|ely spec|
|00000790| 69 66 69 65 73 2e 20 49 | 66 20 61 6c 74 65 72 6e |ifies. I|f altern|
|000007a0| 61 74 69 76 65 20 61 6e | 73 77 65 72 73 20 62 65 |ative an|swers be|
|000007b0| 67 69 6e 20 77 69 74 68 | 20 74 68 65 20 73 61 6d |gin with| the sam|
|000007c0| 65 20 6c 65 74 74 65 72 | 73 20 28 65 2e 67 2e 0d |e letter|s (e.g..|
|000007d0| 22 41 72 61 62 69 63 22 | 20 61 6e 64 20 22 41 72 |"Arabic"| and "Ar|
|000007e0| 6d 65 6e 69 61 6e 22 29 | 20 74 68 65 6e 20 4d 75 |menian")| then Mu|
|000007f0| 6c 74 69 70 6c 65 43 68 | 6f 69 63 65 20 6b 65 65 |ltipleCh|oice kee|
|00000800| 70 73 20 61 63 63 65 70 | 74 69 6e 67 20 63 68 61 |ps accep|ting cha|
|00000810| 72 61 63 74 65 72 73 20 | 75 6e 74 69 6c 20 61 6e |racters |until an|
|00000820| 0d 61 6e 73 77 65 72 20 | 69 73 20 75 6e 69 71 75 |.answer |is uniqu|
|00000830| 65 6c 79 20 64 65 74 65 | 72 6d 69 6e 65 64 2e 20 |ely dete|rmined. |
|00000840| 54 79 70 69 6e 67 20 61 | 6e 79 20 6e 6f 6e 2d 70 |Typing a|ny non-p|
|00000850| 72 69 6e 74 69 6e 67 20 | 63 68 61 72 61 63 74 65 |rinting |characte|
|00000860| 72 20 28 65 2e 67 2e 20 | 52 65 74 75 72 6e 20 6f |r (e.g. |Return o|
|00000870| 72 0d 45 6e 74 65 72 29 | 20 74 65 72 6d 69 6e 61 |r.Enter)| termina|
|00000880| 74 65 73 20 74 68 65 20 | 74 79 70 65 64 20 73 74 |tes the |typed st|
|00000890| 72 69 6e 67 2c 20 65 2e | 67 2e 20 74 6f 20 64 69 |ring, e.|g. to di|
|000008a0| 73 74 69 6e 67 75 69 73 | 68 20 22 61 6e 74 22 20 |stinguis|h "ant" |
|000008b0| 66 72 6f 6d 20 22 61 6e | 74 65 61 74 65 72 22 2e |from "an|teater".|
|000008c0| 0d 49 66 20 74 68 65 20 | 74 79 70 65 64 20 73 74 |.If the |typed st|
|000008d0| 72 69 6e 67 20 64 6f 65 | 73 6e 27 74 20 6d 61 74 |ring doe|sn't mat|
|000008e0| 63 68 20 61 6e 79 20 6f | 66 20 74 68 65 20 73 75 |ch any o|f the su|
|000008f0| 70 70 6c 69 65 64 20 61 | 6e 73 77 65 72 20 73 74 |pplied a|nswer st|
|00000900| 72 69 6e 67 73 20 74 68 | 65 6e 0d 4d 75 6c 74 69 |rings th|en.Multi|
|00000910| 70 6c 65 43 68 6f 69 63 | 65 20 6d 61 6b 65 73 20 |pleChoic|e makes |
|00000920| 74 68 65 20 64 65 66 61 | 75 6c 74 43 68 6f 69 63 |the defa|ultChoic|
|00000930| 65 2e 20 54 68 75 73 20 | 74 68 65 20 75 73 65 72 |e. Thus |the user|
|00000940| 20 63 61 6e 20 73 65 6c | 65 63 74 20 74 68 65 20 | can sel|ect the |
|00000950| 64 65 66 61 75 6c 74 0d | 61 6e 73 77 65 72 20 62 |default.|answer b|
|00000960| 79 20 6a 75 73 74 20 68 | 69 74 74 69 6e 67 20 72 |y just h|itting r|
|00000970| 65 74 75 72 6e 2e 0d 0d | 59 65 73 4f 72 4e 6f 28 |eturn...|YesOrNo(|
|00000980| 29 20 72 65 73 74 72 69 | 63 74 73 20 74 68 65 20 |) restri|cts the |
|00000990| 61 6e 73 77 65 72 73 20 | 74 6f 20 22 59 65 73 22 |answers |to "Yes"|
|000009a0| 20 61 6e 64 20 22 4e 6f | 22 2c 20 77 69 74 68 20 | and "No|", with |
|000009b0| 61 20 42 6f 6f 6c 65 61 | 6e 20 61 72 67 75 6d 65 |a Boolea|n argume|
|000009c0| 6e 74 0d 73 70 65 63 69 | 66 79 69 6e 67 20 74 68 |nt.speci|fying th|
|000009d0| 65 20 64 65 66 61 75 6c | 74 2e 0d 0d 45 58 41 4d |e defaul|t...EXAM|
|000009e0| 50 4c 45 3a 0d 09 73 74 | 61 74 69 63 20 63 68 61 |PLE:..st|atic cha|
|000009f0| 72 20 62 72 65 61 64 5b | 5d 3d 22 42 72 65 61 64 |r bread[|]="Bread|
|00000a00| 22 2c 66 69 73 68 5b 5d | 3d 22 46 69 73 68 22 2c |",fish[]|="Fish",|
|00000a10| 66 6f 77 6c 5b 5d 3d 22 | 46 6f 77 6c 22 3b 0d 09 |fowl[]="|Fowl";..|
|00000a20| 73 74 61 74 69 63 20 63 | 68 61 72 20 2a 62 72 65 |static c|har *bre|
|00000a30| 61 64 46 69 73 68 46 6f | 77 6c 5b 5d 3d 7b 62 72 |adFishFo|wl[]={br|
|00000a40| 65 61 64 2c 66 69 73 68 | 2c 66 6f 77 6c 7d 3b 0d |ead,fish|,fowl};.|
|00000a50| 09 73 68 6f 72 74 20 63 | 68 6f 69 63 65 3d 31 3b |.short c|hoice=1;|
|00000a60| 0d 09 0d 09 2f 2f 20 6e | 65 77 20 77 61 79 0d 09 |....// n|ew way..|
|00000a70| 63 68 6f 69 63 65 3d 43 | 68 6f 6f 73 65 28 63 68 |choice=C|hoose(ch|
|00000a80| 6f 69 63 65 2c 22 57 6f | 75 6c 64 20 79 6f 75 20 |oice,"Wo|uld you |
|00000a90| 6c 69 6b 65 20 74 6f 20 | 65 61 74 20 25 73 3f 5c |like to |eat %s?\|
|00000aa0| 6e 22 2c 62 72 65 61 64 | 46 69 73 68 46 6f 77 6c |n",bread|FishFowl|
|00000ab0| 2c 33 29 3b 09 0d 09 73 | 74 69 6c 6c 48 75 6e 67 |,3);...s|tillHung|
|00000ac0| 72 79 3d 43 68 6f 6f 73 | 65 28 73 74 69 6c 6c 48 |ry=Choos|e(stillH|
|00000ad0| 75 6e 67 72 79 2c 22 44 | 6f 20 79 6f 75 20 77 61 |ungry,"D|o you wa|
|00000ae0| 6e 74 20 64 65 73 73 65 | 72 74 3f 5c 6e 22 2c 6e |nt desse|rt?\n",n|
|00000af0| 6f 59 65 73 2c 32 29 3b | 0d 09 0d 09 2f 2f 20 6f |oYes,2);|....// o|
|00000b00| 6c 64 20 77 61 79 0d 09 | 70 72 69 6e 74 66 28 22 |ld way..|printf("|
|00000b10| 57 6f 75 6c 64 20 79 6f | 75 20 6c 69 6b 65 20 74 |Would yo|u like t|
|00000b20| 6f 20 65 61 74 20 42 72 | 65 61 64 2c 20 46 69 73 |o eat Br|ead, Fis|
|00000b30| 68 2c 20 6f 72 20 46 6f | 77 6c 3f 22 29 3b 0d 09 |h, or Fo|wl?");..|
|00000b40| 63 68 6f 69 63 65 3d 4d | 75 6c 74 69 70 6c 65 43 |choice=M|ultipleC|
|00000b50| 68 6f 69 63 65 28 63 68 | 6f 69 63 65 2c 33 2c 62 |hoice(ch|oice,3,b|
|00000b60| 72 65 61 64 46 69 73 68 | 46 6f 77 6c 29 3b 0d 09 |readFish|Fowl);..|
|00000b70| 70 72 69 6e 74 66 28 22 | 5c 6e 22 29 3b 0d 09 0d |printf("|\n");...|
|00000b80| 09 2f 2f 20 6f 6c 64 20 | 77 61 79 0d 09 70 72 69 |.// old |way..pri|
|00000b90| 6e 74 66 28 22 44 6f 20 | 79 6f 75 20 77 61 6e 74 |ntf("Do |you want|
|00000ba0| 20 64 65 73 73 65 72 74 | 3f 22 29 3b 0d 09 63 68 | dessert|?");..ch|
|00000bb0| 6f 69 63 65 3d 59 65 73 | 4f 72 4e 6f 28 63 68 6f |oice=Yes|OrNo(cho|
|00000bc0| 69 63 65 29 3b 0d 09 70 | 72 69 6e 74 66 28 22 5c |ice);..p|rintf("\|
|00000bd0| 6e 22 29 3b 0d 0d 4e 4f | 54 45 3a 0d 54 68 65 20 |n");..NO|TE:.The |
|00000be0| 64 65 63 6c 61 72 61 74 | 69 6f 6e 73 20 61 62 6f |declarat|ions abo|
|00000bf0| 76 65 20 65 78 70 6c 69 | 63 69 74 6c 79 20 61 6c |ve expli|citly al|
|00000c00| 6c 6f 63 61 74 65 20 73 | 70 61 63 65 20 66 6f 72 |locate s|pace for|
|00000c10| 20 74 68 65 20 73 74 72 | 69 6e 67 73 20 22 42 72 | the str|ings "Br|
|00000c20| 65 61 64 22 20 61 6e 64 | 20 22 46 69 73 68 22 2e |ead" and| "Fish".|
|00000c30| 20 0d 49 6e 20 61 20 73 | 74 61 6e 64 2d 61 6c 6f | .In a s|tand-alo|
|00000c40| 6e 65 20 61 70 70 6c 69 | 63 61 74 69 6f 6e 20 79 |ne appli|cation y|
|00000c50| 6f 75 20 63 6f 75 6c 64 | 20 69 6d 70 6c 69 63 69 |ou could| implici|
|00000c60| 74 6c 79 20 61 6c 6c 6f | 63 61 74 65 20 74 68 61 |tly allo|cate tha|
|00000c70| 74 20 73 70 61 63 65 2c | 0d 09 63 68 61 72 20 2a |t space,|..char *|
|00000c80| 62 72 65 61 64 46 69 73 | 68 46 6f 77 6c 5b 5d 3d |breadFis|hFowl[]=|
|00000c90| 7b 22 42 72 65 61 64 22 | 2c 22 46 69 73 68 22 2c |{"Bread"|,"Fish",|
|00000ca0| 22 46 6f 77 6c 22 7d 3b | 0d 62 75 74 20 74 68 65 |"Fowl"};|.but the|
|00000cb0| 20 54 48 49 4e 4b 20 43 | 20 63 6f 6d 70 69 6c 65 | THINK C| compile|
|00000cc0| 72 20 64 6f 65 73 6e 27 | 74 20 61 6c 6c 6f 77 20 |r doesn'|t allow |
|00000cd0| 74 68 69 73 20 69 6e 20 | 63 6f 64 65 20 72 65 73 |this in |code res|
|00000ce0| 6f 75 72 63 65 73 20 0d | 28 65 2e 67 2e 20 61 20 |ources .|(e.g. a |
|00000cf0| 4d 41 54 4c 41 42 20 4d | 45 58 20 66 69 6c 65 29 |MATLAB M|EX file)|
|00000d00| 2e 0d 0d 48 49 53 54 4f | 52 59 3a 0d 32 2f 31 36 |...HISTO|RY:.2/16|
|00000d10| 2f 39 33 09 64 67 70 09 | 77 72 6f 74 65 20 59 65 |/93.dgp.|wrote Ye|
|00000d20| 73 4f 72 4e 6f 28 29 2e | 0d 35 2f 32 34 2f 39 33 |sOrNo().|.5/24/93|
|00000d30| 09 64 67 70 09 61 64 64 | 65 64 20 4d 75 6c 74 69 |.dgp.add|ed Multi|
|00000d40| 70 6c 65 43 68 6f 69 63 | 65 28 29 2e 0d 39 2f 32 |pleChoic|e()..9/2|
|00000d50| 34 2f 39 33 09 64 67 70 | 09 63 6f 73 6d 65 74 69 |4/93.dgp|.cosmeti|
|00000d60| 63 2e 0d 31 2f 32 35 2f | 39 34 20 64 67 70 09 65 |c..1/25/|94 dgp.e|
|00000d70| 6e 68 61 6e 63 65 64 20 | 4d 75 6c 74 69 70 6c 65 |nhanced |Multiple|
|00000d80| 43 68 6f 69 63 65 28 29 | 20 74 6f 20 61 63 63 65 |Choice()| to acce|
|00000d90| 70 74 20 63 68 61 72 61 | 63 74 65 72 73 20 75 6e |pt chara|cters un|
|00000da0| 74 69 6c 20 74 68 65 79 | 20 75 6e 69 71 75 65 6c |til they| uniquel|
|00000db0| 79 0d 09 09 09 73 70 65 | 63 69 66 79 20 61 6e 20 |y....spe|cify an |
|00000dc0| 61 6e 73 77 65 72 2c 20 | 61 73 20 73 75 67 67 65 |answer, |as sugge|
|00000dd0| 73 74 65 64 20 62 79 20 | 42 61 72 74 20 46 61 72 |sted by |Bart Far|
|00000de0| 65 6c 6c 2e 0d 37 2f 39 | 2f 39 34 09 64 67 70 20 |ell..7/9|/94.dgp |
|00000df0| 61 64 64 65 64 20 43 68 | 6f 6f 73 65 28 29 2e 0d |added Ch|oose()..|
|00000e00| 37 2f 31 33 2f 39 34 09 | 64 67 70 20 72 65 6e 61 |7/13/94.|dgp rena|
|00000e10| 6d 65 64 20 66 69 6c 65 | 20 22 43 68 6f 6f 73 65 |med file| "Choose|
|00000e20| 2e 63 22 2e 0d 38 2f 31 | 2f 39 34 09 64 67 70 20 |.c"..8/1|/94.dgp |
|00000e30| 66 69 78 65 64 20 62 75 | 67 20 69 6e 20 4d 75 6c |fixed bu|g in Mul|
|00000e40| 74 69 70 6c 65 43 68 6f | 69 63 65 28 29 2c 20 49 |tipleCho|ice(), I|
|00000e50| 20 77 61 73 20 62 61 63 | 6b 73 70 61 63 69 6e 67 | was bac|kspacing|
|00000e60| 20 6f 6e 65 20 74 6f 6f | 20 6d 61 6e 79 20 74 69 | one too| many ti|
|00000e70| 6d 65 73 2e 0d 39 2f 32 | 31 2f 39 34 20 64 67 70 |mes..9/2|1/94 dgp|
|00000e80| 20 61 64 64 65 64 20 66 | 66 6c 75 73 68 28 73 74 | added f|flush(st|
|00000e90| 64 69 6e 29 20 74 6f 20 | 4d 75 6c 74 69 70 6c 65 |din) to |Multiple|
|00000ea0| 43 68 6f 69 63 65 28 29 | 2c 20 77 68 69 63 68 20 |Choice()|, which |
|00000eb0| 77 6f 72 6b 73 20 62 65 | 74 74 65 72 20 77 68 65 |works be|tter whe|
|00000ec0| 6e 0d 09 09 09 74 68 65 | 72 65 27 73 20 6e 6f 20 |n....the|re's no |
|00000ed0| 75 6e 62 75 66 66 65 72 | 65 64 20 69 6e 70 75 74 |unbuffer|ed input|
|00000ee0| 2e 0d 31 2f 35 2f 39 35 | 20 64 67 70 20 75 70 64 |..1/5/95| dgp upd|
|00000ef0| 61 74 65 64 20 74 6f 20 | 43 57 35 2c 20 65 6c 69 |ated to |CW5, eli|
|00000f00| 6d 69 6e 61 74 69 6e 67 | 20 74 68 65 20 63 6c 75 |minating| the clu|
|00000f10| 64 67 65 73 20 77 69 74 | 68 20 53 49 4f 55 58 74 |dges wit|h SIOUXt|
|00000f20| 65 78 74 57 69 6e 64 6f | 77 2e 0d 36 2f 31 38 2f |extWindo|w..6/18/|
|00000f30| 39 35 20 64 67 70 20 63 | 68 61 6e 67 65 64 20 22 |95 dgp c|hanged "|
|00000f40| 61 62 6f 72 74 22 20 74 | 6f 20 22 65 78 69 74 22 |abort" t|o "exit"|
|00000f50| 20 66 6f 72 20 62 65 74 | 74 65 72 20 63 6f 6d 70 | for bet|ter comp|
|00000f60| 61 74 69 62 69 6c 69 74 | 79 20 77 69 74 68 20 43 |atibilit|y with C|
|00000f70| 57 20 61 74 65 78 69 74 | 28 29 2e 0d 2a 2f 0d 23 |W atexit|()..*/.#|
|00000f80| 69 6e 63 6c 75 64 65 20 | 22 56 69 64 65 6f 54 6f |include |"VideoTo|
|00000f90| 6f 6c 62 6f 78 2e 68 22 | 0d 23 69 66 20 21 64 65 |olbox.h"|.#if !de|
|00000fa0| 66 69 6e 65 64 28 5f 5f | 54 59 50 45 53 5f 5f 29 |fined(__|TYPES__)|
|00000fb0| 0d 09 74 79 70 65 64 65 | 66 20 75 6e 73 69 67 6e |..typede|f unsign|
|00000fc0| 65 64 20 63 68 61 72 20 | 42 6f 6f 6c 65 61 6e 3b |ed char |Boolean;|
|00000fd0| 0d 23 65 6e 64 69 66 0d | 23 64 65 66 69 6e 65 20 |.#endif.|#define |
|00000fe0| 66 72 65 65 28 70 74 72 | 29 20 44 69 73 70 6f 73 |free(ptr|) Dispos|
|00000ff0| 65 50 74 72 28 28 50 74 | 72 29 28 70 74 72 29 29 |ePtr((Pt|r)(ptr))|
|00001000| 0d 23 64 65 66 69 6e 65 | 20 6d 61 6c 6c 6f 63 28 |.#define| malloc(|
|00001010| 62 79 74 65 73 29 20 28 | 76 6f 69 64 20 2a 29 4e |bytes) (|void *)N|
|00001020| 65 77 50 74 72 28 62 79 | 74 65 73 29 0d 73 74 61 |ewPtr(by|tes).sta|
|00001030| 74 69 63 20 63 68 61 72 | 20 6e 6f 5b 5d 3d 22 4e |tic char| no[]="N|
|00001040| 6f 22 2c 79 65 73 5b 5d | 3d 22 59 65 73 22 3b 0d |o",yes[]|="Yes";.|
|00001050| 63 68 61 72 20 2a 6e 6f | 59 65 73 5b 5d 3d 7b 6e |char *no|Yes[]={n|
|00001060| 6f 2c 79 65 73 7d 3b 0d | 0d 69 6e 74 20 43 68 6f |o,yes};.|.int Cho|
|00001070| 6f 73 65 28 69 6e 74 20 | 64 65 66 61 75 6c 74 43 |ose(int |defaultC|
|00001080| 68 6f 69 63 65 2c 63 6f | 6e 73 74 20 63 68 61 72 |hoice,co|nst char|
|00001090| 20 2a 71 75 65 72 79 2c | 63 68 61 72 20 2a 63 68 | *query,|char *ch|
|000010a0| 6f 69 63 65 73 5b 5d 2c | 69 6e 74 20 6e 29 0d 7b |oices[],|int n).{|
|000010b0| 0d 09 42 6f 6f 6c 65 61 | 6e 20 6e 65 77 6c 69 6e |..Boolea|n newlin|
|000010c0| 65 3b 0d 09 69 6e 74 20 | 63 68 6f 69 63 65 3b 0d |e;..int |choice;.|
|000010d0| 09 73 74 61 74 69 63 20 | 63 68 61 72 20 2a 73 74 |.static |char *st|
|000010e0| 72 69 6e 67 3d 4e 55 4c | 4c 3b 0d 09 63 68 61 72 |ring=NUL|L;..char|
|000010f0| 20 2a 63 68 6f 69 63 65 | 4c 69 73 74 3b 0d 0d 09 | *choice|List;...|
|00001100| 6e 65 77 6c 69 6e 65 3d | 28 71 75 65 72 79 5b 73 |newline=|(query[s|
|00001110| 74 72 6c 65 6e 28 71 75 | 65 72 79 29 2d 31 5d 3d |trlen(qu|ery)-1]=|
|00001120| 3d 27 5c 6e 27 29 3b 0d | 09 63 68 6f 69 63 65 4c |='\n');.|.choiceL|
|00001130| 69 73 74 3d 43 68 6f 69 | 63 65 53 74 72 28 63 68 |ist=Choi|ceStr(ch|
|00001140| 6f 69 63 65 73 2c 6e 29 | 3b 0d 09 73 74 72 69 6e |oices,n)|;..strin|
|00001150| 67 3d 6d 61 6c 6c 6f 63 | 28 73 74 72 6c 65 6e 28 |g=malloc|(strlen(|
|00001160| 71 75 65 72 79 29 2b 73 | 74 72 6c 65 6e 28 63 68 |query)+s|trlen(ch|
|00001170| 6f 69 63 65 4c 69 73 74 | 29 2b 31 29 3b 0d 09 61 |oiceList|)+1);..a|
|00001180| 73 73 65 72 74 28 73 74 | 72 69 6e 67 21 3d 4e 55 |ssert(st|ring!=NU|
|00001190| 4c 4c 29 3b 0d 2f 2f 72 | 65 74 75 72 6e 20 64 65 |LL);.//r|eturn de|
|000011a0| 66 61 75 6c 74 43 68 6f | 69 63 65 3d 31 3b 0d 09 |faultCho|ice=1;..|
|000011b0| 73 70 72 69 6e 74 66 28 | 73 74 72 69 6e 67 2c 71 |sprintf(|string,q|
|000011c0| 75 65 72 79 2c 63 68 6f | 69 63 65 4c 69 73 74 29 |uery,cho|iceList)|
|000011d0| 3b 0d 09 69 66 28 6e 65 | 77 6c 69 6e 65 29 73 74 |;..if(ne|wline)st|
|000011e0| 72 69 6e 67 5b 73 74 72 | 6c 65 6e 28 73 74 72 69 |ring[str|len(stri|
|000011f0| 6e 67 29 2d 31 5d 3d 30 | 3b 09 2f 2f 20 73 74 72 |ng)-1]=0|;.// str|
|00001200| 69 70 20 74 68 65 20 74 | 72 61 69 6c 69 6e 67 20 |ip the t|railing |
|00001210| 6e 65 77 6c 69 6e 65 3b | 20 70 72 69 6e 74 20 69 |newline;| print i|
|00001220| 74 20 6c 61 74 65 72 2e | 0d 09 42 72 65 61 6b 4c |t later.|..BreakL|
|00001230| 69 6e 65 73 28 73 74 72 | 69 6e 67 2c 38 30 29 3b |ines(str|ing,80);|
|00001240| 0d 09 70 72 69 6e 74 66 | 28 22 25 73 22 2c 73 74 |..printf|("%s",st|
|00001250| 72 69 6e 67 29 3b 0d 09 | 66 72 65 65 28 73 74 72 |ring);..|free(str|
|00001260| 69 6e 67 29 3b 0d 09 63 | 68 6f 69 63 65 3d 4d 75 |ing);..c|hoice=Mu|
|00001270| 6c 74 69 70 6c 65 43 68 | 6f 69 63 65 28 64 65 66 |ltipleCh|oice(def|
|00001280| 61 75 6c 74 43 68 6f 69 | 63 65 2c 6e 2c 63 68 6f |aultChoi|ce,n,cho|
|00001290| 69 63 65 73 29 3b 0d 09 | 69 66 28 6e 65 77 6c 69 |ices);..|if(newli|
|000012a0| 6e 65 29 70 72 69 6e 74 | 66 28 22 5c 6e 22 29 3b |ne)print|f("\n");|
|000012b0| 0d 09 72 65 74 75 72 6e | 20 63 68 6f 69 63 65 3b |..return| choice;|
|000012c0| 0d 7d 0d 0d 42 6f 6f 6c | 65 61 6e 20 59 65 73 4f |.}..Bool|ean YesO|
|000012d0| 72 4e 6f 28 42 6f 6f 6c | 65 61 6e 20 64 65 66 61 |rNo(Bool|ean defa|
|000012e0| 75 6c 74 43 68 6f 69 63 | 65 29 0d 2f 2a 20 41 63 |ultChoic|e)./* Ac|
|000012f0| 63 65 70 74 20 22 79 22 | 20 6f 72 20 22 6e 22 20 |cept "y"| or "n" |
|00001300| 61 6e 64 20 73 70 65 6c | 6c 20 6f 75 74 20 22 59 |and spel|l out "Y|
|00001310| 65 73 22 20 6f 72 20 22 | 4e 6f 22 2e 20 41 6e 79 |es" or "|No". Any|
|00001320| 74 68 69 6e 67 20 65 6c | 73 65 20 67 65 74 73 20 |thing el|se gets |
|00001330| 64 65 66 61 75 6c 74 43 | 68 6f 69 63 65 2e 20 2a |defaultC|hoice. *|
|00001340| 2f 0d 7b 0d 09 72 65 74 | 75 72 6e 20 4d 75 6c 74 |/.{..ret|urn Mult|
|00001350| 69 70 6c 65 43 68 6f 69 | 63 65 28 64 65 66 61 75 |ipleChoi|ce(defau|
|00001360| 6c 74 43 68 6f 69 63 65 | 2c 32 2c 6e 6f 59 65 73 |ltChoice|,2,noYes|
|00001370| 29 3b 0d 7d 0d 0d 69 6e | 74 20 4d 75 6c 74 69 70 |);.}..in|t Multip|
|00001380| 6c 65 43 68 6f 69 63 65 | 28 73 68 6f 72 74 20 64 |leChoice|(short d|
|00001390| 65 66 61 75 6c 74 43 68 | 6f 69 63 65 2c 73 68 6f |efaultCh|oice,sho|
|000013a0| 72 74 20 6e 43 68 6f 69 | 63 65 73 2c 63 68 61 72 |rt nChoi|ces,char|
|000013b0| 20 2a 63 68 6f 69 63 65 | 73 5b 5d 29 0d 7b 0d 09 | *choice|s[]).{..|
|000013c0| 63 68 61 72 20 63 2c 73 | 5b 36 34 5d 3b 0d 09 73 |char c,s|[64];..s|
|000013d0| 68 6f 72 74 20 69 2c 6a | 2c 63 68 6f 69 63 65 2c |hort i,j|,choice,|
|000013e0| 6d 61 74 63 68 2c 6d 61 | 74 63 68 65 73 2c 6b 3b |match,ma|tches,k;|
|000013f0| 0d 0d 09 70 72 69 6e 74 | 66 28 22 20 28 25 73 29 |...print|f(" (%s)|
|00001400| 3a 22 2c 63 68 6f 69 63 | 65 73 5b 64 65 66 61 75 |:",choic|es[defau|
|00001410| 6c 74 43 68 6f 69 63 65 | 5d 29 3b 0d 09 66 66 6c |ltChoice|]);..ffl|
|00001420| 75 73 68 28 73 74 64 6f | 75 74 29 3b 0d 09 66 6f |ush(stdo|ut);..fo|
|00001430| 72 28 6b 3d 30 3b 6b 3c | 73 69 7a 65 6f 66 28 73 |r(k=0;k<|sizeof(s|
|00001440| 29 2d 31 3b 6b 2b 2b 29 | 7b 0d 09 09 6d 61 74 63 |)-1;k++)|{...matc|
|00001450| 68 65 73 3d 30 3b 0d 09 | 09 64 6f 7b 0d 09 09 09 |hes=0;..|.do{....|
|00001460| 63 3d 67 65 74 63 68 61 | 72 55 6e 62 75 66 66 65 |c=getcha|rUnbuffe|
|00001470| 72 65 64 28 29 3b 0d 09 | 09 7d 77 68 69 6c 65 28 |red();..|.}while(|
|00001480| 63 3d 3d 45 4f 46 29 3b | 0d 09 09 69 66 28 63 3d |c==EOF);|...if(c=|
|00001490| 3d 31 34 29 65 78 69 74 | 28 31 29 3b 09 09 09 2f |=14)exit|(1);.../|
|000014a0| 2a 20 43 72 75 64 65 20 | 74 65 73 74 20 66 6f 72 |* Crude |test for|
|000014b0| 20 63 6f 6d 6d 61 6e 64 | 2d 70 65 72 69 6f 64 2e | command|-period.|
|000014c0| 20 2a 2f 0d 09 09 69 66 | 28 21 69 73 70 72 69 6e | */...if|(!isprin|
|000014d0| 74 28 63 29 29 63 3d 30 | 3b 0d 09 09 73 5b 6b 5d |t(c))c=0|;...s[k]|
|000014e0| 3d 63 3b 0d 09 09 73 5b | 6b 2b 31 5d 3d 30 3b 0d |=c;...s[|k+1]=0;.|
|000014f0| 09 09 66 6f 72 28 69 3d | 30 3b 69 3c 6e 43 68 6f |..for(i=|0;i<nCho|
|00001500| 69 63 65 73 3b 69 2b 2b | 29 7b 0d 09 09 09 6d 61 |ices;i++|){....ma|
|00001510| 74 63 68 3d 31 3b 0d 09 | 09 09 66 6f 72 28 6a 3d |tch=1;..|..for(j=|
|00001520| 30 3b 6a 3c 3d 6b 3b 6a | 2b 2b 29 6d 61 74 63 68 |0;j<=k;j|++)match|
|00001530| 26 3d 28 74 6f 6c 6f 77 | 65 72 28 73 5b 6a 5d 29 |&=(tolow|er(s[j])|
|00001540| 3d 3d 74 6f 6c 6f 77 65 | 72 28 63 68 6f 69 63 65 |==tolowe|r(choice|
|00001550| 73 5b 69 5d 5b 6a 5d 29 | 29 3b 0d 09 09 09 69 66 |s[i][j])|);....if|
|00001560| 28 6d 61 74 63 68 29 7b | 0d 09 09 09 09 63 68 6f |(match){|.....cho|
|00001570| 69 63 65 3d 69 3b 0d 09 | 09 09 09 6d 61 74 63 68 |ice=i;..|...match|
|00001580| 65 73 2b 2b 3b 0d 09 09 | 09 7d 0d 09 09 7d 0d 09 |es++;...|.}...}..|
|00001590| 09 69 66 28 6d 61 74 63 | 68 65 73 3c 3d 31 20 7c |.if(matc|hes<=1 ||
|000015a0| 7c 20 73 5b 6b 5d 3d 3d | 30 29 62 72 65 61 6b 3b || s[k]==|0)break;|
|000015b0| 0d 09 09 70 72 69 6e 74 | 66 28 22 25 63 22 2c 63 |...print|f("%c",c|
|000015c0| 29 3b 0d 09 09 66 66 6c | 75 73 68 28 73 74 64 6f |);...ffl|ush(stdo|
|000015d0| 75 74 29 3b 0d 09 7d 0d | 09 66 66 6c 75 73 68 28 |ut);..}.|.fflush(|
|000015e0| 73 74 64 69 6e 29 3b 09 | 2f 2f 20 67 65 74 20 72 |stdin);.|// get r|
|000015f0| 69 64 20 6f 66 20 61 6e | 79 20 75 6e 75 73 65 64 |id of an|y unused|
|00001600| 20 69 6e 70 75 74 0d 09 | 0d 09 2f 2a 20 45 72 61 | input..|../* Era|
|00001610| 73 65 20 70 61 72 74 69 | 61 6c 20 61 6e 73 77 65 |se parti|al answe|
|00001620| 72 2c 20 77 68 69 63 68 | 20 63 6f 75 6c 64 20 62 |r, which| could b|
|00001630| 65 20 6c 6f 6e 67 65 72 | 20 74 68 61 6e 20 74 68 |e longer| than th|
|00001640| 65 20 64 65 66 61 75 6c | 74 20 61 6e 73 77 65 72 |e defaul|t answer|
|00001650| 2e 20 2a 2f 0d 09 2f 2a | 20 2d 31 20 62 65 63 61 |. */../*| -1 beca|
|00001660| 75 73 65 20 77 65 20 64 | 69 64 6e 27 74 20 70 72 |use we d|idn't pr|
|00001670| 69 6e 74 20 74 68 65 20 | 6c 61 73 74 20 63 68 61 |int the |last cha|
|00001680| 72 61 63 74 65 72 20 74 | 79 70 65 64 20 62 79 20 |racter t|yped by |
|00001690| 74 68 65 20 75 73 65 72 | 2e 20 2a 2f 0d 09 6b 3d |the user|. */..k=|
|000016a0| 73 74 72 6c 65 6e 28 73 | 29 2d 31 3b 0d 09 66 6f |strlen(s|)-1;..fo|
|000016b0| 72 28 6a 3d 30 3b 6a 3c | 6b 3b 6a 2b 2b 29 70 72 |r(j=0;j<|k;j++)pr|
|000016c0| 69 6e 74 66 28 22 5c 62 | 20 5c 62 22 29 3b 0d 09 |intf("\b| \b");..|
|000016d0| 0d 09 2f 2a 20 50 72 69 | 6e 74 20 61 6e 73 77 65 |../* Pri|nt answe|
|000016e0| 72 20 2a 2f 0d 09 69 66 | 28 6d 61 74 63 68 65 73 |r */..if|(matches|
|000016f0| 3d 3d 30 29 63 68 6f 69 | 63 65 3d 64 65 66 61 75 |==0)choi|ce=defau|
|00001700| 6c 74 43 68 6f 69 63 65 | 3b 0d 09 70 72 69 6e 74 |ltChoice|;..print|
|00001710| 66 28 22 25 73 2e 22 2c | 63 68 6f 69 63 65 73 5b |f("%s.",|choices[|
|00001720| 63 68 6f 69 63 65 5d 29 | 3b 0d 09 66 66 6c 75 73 |choice])|;..fflus|
|00001730| 68 28 73 74 64 6f 75 74 | 29 3b 0d 09 72 65 74 75 |h(stdout|);..retu|
|00001740| 72 6e 20 63 68 6f 69 63 | 65 3b 0d 7d 0d 0d 63 68 |rn choic|e;.}..ch|
|00001750| 61 72 20 2a 43 68 6f 69 | 63 65 53 74 72 28 63 68 |ar *Choi|ceStr(ch|
|00001760| 61 72 20 2a 63 68 6f 69 | 63 65 73 5b 5d 2c 69 6e |ar *choi|ces[],in|
|00001770| 74 20 6e 43 68 6f 69 63 | 65 73 29 0d 7b 0d 09 69 |t nChoic|es).{..i|
|00001780| 6e 74 20 69 2c 73 69 7a | 65 3b 0d 09 73 74 61 74 |nt i,siz|e;..stat|
|00001790| 69 63 20 63 68 61 72 20 | 2a 73 74 72 69 6e 67 3d |ic char |*string=|
|000017a0| 4e 55 4c 4c 3b 0d 09 0d | 09 73 69 7a 65 3d 30 3b |NULL;...|.size=0;|
|000017b0| 0d 09 66 6f 72 28 69 3d | 30 3b 69 3c 6e 43 68 6f |..for(i=|0;i<nCho|
|000017c0| 69 63 65 73 3b 69 2b 2b | 29 73 69 7a 65 2b 3d 73 |ices;i++|)size+=s|
|000017d0| 74 72 6c 65 6e 28 63 68 | 6f 69 63 65 73 5b 69 5d |trlen(ch|oices[i]|
|000017e0| 29 2b 36 3b 0d 09 73 74 | 72 69 6e 67 3d 72 65 61 |)+6;..st|ring=rea|
|000017f0| 6c 6c 6f 63 28 73 74 72 | 69 6e 67 2c 73 69 7a 65 |lloc(str|ing,size|
|00001800| 29 3b 0d 09 61 73 73 65 | 72 74 28 73 74 72 69 6e |);..asse|rt(strin|
|00001810| 67 21 3d 4e 55 4c 4c 29 | 3b 0d 09 73 74 72 69 6e |g!=NULL)|;..strin|
|00001820| 67 5b 30 5d 3d 30 3b 0d | 09 66 6f 72 28 69 3d 30 |g[0]=0;.|.for(i=0|
|00001830| 3b 69 3c 6e 43 68 6f 69 | 63 65 73 3b 69 2b 2b 29 |;i<nChoi|ces;i++)|
|00001840| 7b 0d 09 09 73 70 72 69 | 6e 74 66 28 73 74 72 69 |{...spri|ntf(stri|
|00001850| 6e 67 2c 22 25 73 25 73 | 22 2c 73 74 72 69 6e 67 |ng,"%s%s|",string|
|00001860| 2c 63 68 6f 69 63 65 73 | 5b 69 5d 29 3b 0d 09 09 |,choices|[i]);...|
|00001870| 69 66 28 69 3c 6e 43 68 | 6f 69 63 65 73 2d 32 29 |if(i<nCh|oices-2)|
|00001880| 73 70 72 69 6e 74 66 28 | 73 74 72 69 6e 67 2c 22 |sprintf(|string,"|
|00001890| 25 73 2c 20 22 2c 73 74 | 72 69 6e 67 29 3b 0d 09 |%s, ",st|ring);..|
|000018a0| 09 69 66 28 69 3d 3d 6e | 43 68 6f 69 63 65 73 2d |.if(i==n|Choices-|
|000018b0| 32 29 7b 0d 09 09 09 69 | 66 28 6e 43 68 6f 69 63 |2){....i|f(nChoic|
|000018c0| 65 73 3e 32 29 73 70 72 | 69 6e 74 66 28 73 74 72 |es>2)spr|intf(str|
|000018d0| 69 6e 67 2c 22 25 73 2c | 20 6f 72 20 22 2c 73 74 |ing,"%s,| or ",st|
|000018e0| 72 69 6e 67 29 3b 0d 09 | 09 09 65 6c 73 65 20 73 |ring);..|..else s|
|000018f0| 70 72 69 6e 74 66 28 73 | 74 72 69 6e 67 2c 22 25 |printf(s|tring,"%|
|00001900| 73 20 6f 72 20 22 2c 73 | 74 72 69 6e 67 29 3b 0d |s or ",s|tring);.|
|00001910| 09 09 7d 0d 09 09 69 66 | 28 69 3d 3d 6e 43 68 6f |..}...if|(i==nCho|
|00001920| 69 63 65 73 2d 31 29 73 | 70 72 69 6e 74 66 28 73 |ices-1)s|printf(s|
|00001930| 74 72 69 6e 67 2c 22 25 | 73 22 2c 73 74 72 69 6e |tring,"%|s",strin|
|00001940| 67 29 3b 0d 09 7d 0d 09 | 72 65 74 75 72 6e 20 73 |g);..}..|return s|
|00001950| 74 72 69 6e 67 3b 0d 7d | 0d 00 00 00 00 00 00 00 |tring;.}|........|
|00001960| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001970| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001980| 00 00 01 00 00 00 01 c6 | 00 00 00 c6 00 00 00 5e |........|.......^|
|00001990| 6d 70 f0 38 04 15 10 02 | da f1 01 05 6d 68 f0 32 |mp.8....|....mh.2|
|000019a0| 04 1d 50 03 1e 0b 00 0f | ab 70 f0 30 04 28 58 03 |..P.....|.p.0.(X.|
|000019b0| 08 43 68 6f 6f 73 65 2e | 63 6f 02 00 00 00 54 45 |.Choose.|co....TE|
|000019c0| 58 54 43 57 49 45 01 00 | 00 28 00 c0 00 00 00 00 |XTCWIE..|.(......|
|000019d0| 00 00 54 45 58 54 43 57 | 49 45 01 00 00 28 00 c0 |..TEXTCW|IE...(..|
|000019e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000019f0| 00 00 aa 49 11 96 00 00 | 18 d9 00 00 02 24 70 65 |...I....|.....$pe|
|00001a00| 63 61 69 6c 20 4d 65 6e | 75 09 4e 65 77 46 6f 6c |cail Men|u.NewFol|
|00001a10| 64 65 72 07 55 74 69 6c | 69 74 79 05 41 62 6f 75 |der.Util|ity.Abou|
|00001a20| 74 0a 74 69 6e 79 46 69 | 6e 64 65 72 07 4f 70 74 |t.tinyFi|nder.Opt|
|00001a30| 69 6f 6e 73 0b 48 6f 74 | 20 4b 65 79 73 2e 2e 2e |ions.Hot| Keys...|
|00001a40| 0c 53 70 65 63 69 61 6c | 20 4b 65 79 73 09 4b 65 |.Special| Keys.Ke|
|00001a50| 79 20 6e 61 6d 65 73 04 | 48 65 6c 70 04 46 69 6c |y names.|Help.Fil|
|00001a60| 65 0b 59 65 73 4e 6f 20 | 41 6c 65 72 74 07 53 79 |e.YesNo |Alert.Sy|
|00001a70| 73 20 45 72 72 11 45 72 | 72 6f 72 20 74 61 62 6c |s Err.Er|ror tabl|
|00001a80| 00 00 00 1e 00 29 00 07 | 01 73 02 23 00 29 00 07 |.....)..|.s.#.)..|
|00001a90| 01 73 02 23 00 00 17 43 | 00 00 00 00 00 00 00 00 |.s.#...C|........|
|00001aa0| 00 00 00 00 00 4c 00 04 | 00 00 0e a0 00 00 0e a6 |.....L..|........|
|00001ab0| 07 43 68 6f 6f 73 65 00 | 00 00 10 e6 00 00 10 ed |.Choose.|........|
|00001ac0| 07 59 65 73 4f 72 4e 6f | 00 00 11 94 00 00 11 a2 |.YesOrNo|........|
|00001ad0| 0f 4d 75 6c 74 69 70 6c | 65 43 68 6f 69 63 65 00 |.Multipl|eChoice.|
|00001ae0| 00 00 15 40 00 00 15 49 | 09 43 68 6f 69 63 65 53 |...@...I|.ChoiceS|
|00001af0| 74 72 00 00 00 48 00 09 | 4d 6f 6e 61 63 6f 00 00 |tr...H..|Monaco..|
|00001b00| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001b10| 00 00 00 00 00 00 00 00 | 00 03 00 04 00 9c 00 97 |........|........|
|00001b20| 01 db 02 f6 00 9c 00 97 | 01 db 02 f6 ad 65 04 35 |........|.....e.5|
|00001b30| 00 00 0d b0 00 00 0d b5 | 00 00 0b f9 00 00 00 00 |........|........|
|00001b40| 00 04 00 01 00 01 00 00 | 01 00 00 00 01 c6 00 00 |........|........|
|00001b50| 00 c6 00 00 00 5e 01 bb | c7 28 36 b8 00 00 00 1c |.....^..|.(6.....|
|00001b60| 00 5e 00 01 4d 50 53 52 | 00 02 00 12 4d 57 42 42 |.^..MPSR|....MWBB|
|00001b70| 00 00 00 36 03 f0 ff ff | 00 00 00 00 00 00 00 00 |...6....|........|
|00001b80| 03 ef ff ff 00 00 00 22 | 00 00 00 00 03 ed ff ff |......."|........|
|00001b90| 00 00 00 72 00 00 00 00 | 03 f0 ff ff 00 00 00 be |...r....|........|
|00001ba0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001bb0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001bc0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001bd0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001be0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001bf0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+