🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.msdos.programmer
Article #102

Help referencing pointers in C++

#102
From: you
Date: Sun, 26 Jul 1992 23:06
45 lines
1999 bytes
Hello,
  I'm playing with C++, teaching it to myself.  What I would like to know how to
do is reference certain pointers in a weird way....let me explain.  I'm
using a trie ADT.  Each node has 27 children, A-Z plus one to see if it's a word
or not.  It's a type of spell checker.  You trace down the tree the letters of
the word and when you're done, you check to see if it's a valid word or not.  
Of course, if along that way you find a path is NULL then it isn't a word.  What
I had hoped could be done is something like this, where the word is in the
variable "inword":

	char1 = toupper(inword[count]);
	if (dictionary->char1==NULL)
		notfound=1;
	else
		dictionary=dictionary->char1;

Count keeps tract of which letter the program is searching for and when count
equals the length of the word, you check to see if the flag is set and if
it is, then it's a word, else it isn't.  I've looked at the enum datatype
but I haven't had any luck with it.  Any help would be greatly
appreciated.  What I don't want to do is this:

      switch(*char1) {
         case 'A' : {
            if (current->a==NULL)
               done = 1;
            else
               current=current->a;
            };
         case 'B' : {
            if (current->a==NULL)
               done = 1;
            else
               current=current->b;
            };
         case 'C' : {
            if (current->c==NULL)
               done = 1;
            else
               current=current->c;
            };
.......

					Thanks, 
						Kevin
Technical Details
Message-ID: <14vb6jINNlr9@matt.ksu.ksu.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!matt.ksu.ksu.edu!news

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!matt.ksu.ksu.edu!news
From: you@matt.ksu.ksu.edu
Newsgroups: alt.msdos.programmer,comp.os.msdos.programmer,comp.programming,comp.unix.programmer
Subject: Help referencing pointers in C++
Date: 26 Jul 1992 18:06:59 -0500
Organization: Kansas State University
Lines: 45
Message-ID: <14vb6jINNlr9@matt.ksu.ksu.edu>
NNTP-Posting-Host: matt.ksu.ksu.edu