home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / alt / msdos / programm / 2072 < prev    next >
Encoding:
Internet Message Format  |  1992-07-26  |  2.0 KB

  1. Xref: sparky alt.msdos.programmer:2072 comp.os.msdos.programmer:8096 comp.programming:2112 comp.unix.programmer:3927
  2. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!matt.ksu.ksu.edu!news
  3. From: you@matt.ksu.ksu.edu
  4. Newsgroups: alt.msdos.programmer,comp.os.msdos.programmer,comp.programming,comp.unix.programmer
  5. Subject: Help referencing pointers in C++
  6. Date: 26 Jul 1992 18:06:59 -0500
  7. Organization: Kansas State University
  8. Lines: 45
  9. Message-ID: <14vb6jINNlr9@matt.ksu.ksu.edu>
  10. NNTP-Posting-Host: matt.ksu.ksu.edu
  11.  
  12. Hello,
  13.   I'm playing with C++, teaching it to myself.  What I would like to know how to
  14. do is reference certain pointers in a weird way....let me explain.  I'm
  15. using a trie ADT.  Each node has 27 children, A-Z plus one to see if it's a word
  16. or not.  It's a type of spell checker.  You trace down the tree the letters of
  17. the word and when you're done, you check to see if it's a valid word or not.  
  18. Of course, if along that way you find a path is NULL then it isn't a word.  What
  19. I had hoped could be done is something like this, where the word is in the
  20. variable "inword":
  21.  
  22.     char1 = toupper(inword[count]);
  23.     if (dictionary->char1==NULL)
  24.         notfound=1;
  25.     else
  26.         dictionary=dictionary->char1;
  27.  
  28. Count keeps tract of which letter the program is searching for and when count
  29. equals the length of the word, you check to see if the flag is set and if
  30. it is, then it's a word, else it isn't.  I've looked at the enum datatype
  31. but I haven't had any luck with it.  Any help would be greatly
  32. appreciated.  What I don't want to do is this:
  33.  
  34.       switch(*char1) {
  35.          case 'A' : {
  36.             if (current->a==NULL)
  37.                done = 1;
  38.             else
  39.                current=current->a;
  40.             };
  41.          case 'B' : {
  42.             if (current->a==NULL)
  43.                done = 1;
  44.             else
  45.                current=current->b;
  46.             };
  47.          case 'C' : {
  48.             if (current->c==NULL)
  49.                done = 1;
  50.             else
  51.                current=current->c;
  52.             };
  53. .......
  54.  
  55.                     Thanks, 
  56.                         Kevin
  57.