Click here to Skip to main content
16,010,876 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Invalidate window... Pin
Paul M Watt13-Dec-02 5:06
mentorPaul M Watt13-Dec-02 5:06 
GeneralDetecting 16/32 bit DLLs Pin
Victor Boctor12-Dec-02 15:42
Victor Boctor12-Dec-02 15:42 
GeneralRe: Detecting 16/32 bit DLLs Pin
Michael Dunn12-Dec-02 17:12
sitebuilderMichael Dunn12-Dec-02 17:12 
GeneralRe: Detecting 16/32 bit DLLs Pin
Victor Boctor12-Dec-02 20:05
Victor Boctor12-Dec-02 20:05 
GeneralRe: Detecting 16/32 bit DLLs Pin
Roman Fadeyev12-Dec-02 23:55
Roman Fadeyev12-Dec-02 23:55 
GeneralRe: Detecting 16/32 bit DLLs Pin
Dudi Avramov15-Dec-02 2:12
Dudi Avramov15-Dec-02 2:12 
GeneralRe: Detecting 16/32 bit DLLs Pin
Victor Boctor1-Feb-03 2:52
Victor Boctor1-Feb-03 2:52 
GeneralArhh.... Tree Problem.... Pin
Nick Parker12-Dec-02 12:39
protectorNick Parker12-Dec-02 12:39 
Ok, I keep hitting else statement saying a 'Duplicate value found in tree' following the first insert. I haven't a clue as to why, does anyone see something I am missing? Mad | :mad: Thanks in advance.

struct stars
{
	char name[25];
	char designation[12];
	char constellation[3];
	unsigned int right_asc_one;
	unsigned int right_asc_two;
	signed int decline_one;
	unsigned int decline_two;
	float vis_magnitude;
};


void BinaryTree::InsertNode(stars value)
{
	TreeNode *newNode,			// Pointer to a new node
		     *nodePtr;			// Pointer to traverse the tree

	// Create a new node
	newNode = new TreeNode;

	// Copy values from stars struct into new node.
	strcpy(newNode->value.name, value.name);
	strcpy(newNode->value.designation, value.designation);
	strcpy(newNode->value.constellation,value.constellation);
	newNode->value.right_asc_one = value.right_asc_one;
	newNode->value.right_asc_two = value.right_asc_two;
	newNode->value.decline_one = value.decline_one;
	newNode->value.decline_two = value.decline_two;

	// Set the left and right pointers to NULL.
	newNode->left = newNode->right = NULL;

	if (!root)	// Is the tree empty?
		root = newNode;
	else
	{
		nodePtr = root; 
		while (nodePtr != NULL)
		{
			if (strcmp(value.name,nodePtr->value.name) < 0)
			{
				if (nodePtr->left)
					nodePtr = nodePtr->left;
				else
				{
					nodePtr->left = newNode;
					break;
				}
			}
			else if (strcmp(value.name,nodePtr->value.name) > 0)
			{
				if (nodePtr->right)
					nodePtr = nodePtr->right;
				else
				{
					nodePtr->right = newNode;
					break;
				}
			}
			else
			{
                                     // always being hit after the second insert call.
				cout << "Duplicate value found in tree.\n"; 				
break;
			}
		}		
	} // end of while loop
} //end of function





Nick Parker

Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein


GeneralRe: Arhh.... Tree Problem.... Pin
Rage13-Dec-02 1:14
professionalRage13-Dec-02 1:14 
Question_bstr_t with CString::Format()? Pin
Member 9612-Dec-02 11:26
Member 9612-Dec-02 11:26 
AnswerRe: _bstr_t with CString::Format()? Pin
Dave Bryant12-Dec-02 12:01
Dave Bryant12-Dec-02 12:01 
GeneralRe: _bstr_t with CString::Format()? Pin
Member 9612-Dec-02 13:06
Member 9612-Dec-02 13:06 
AnswerRe: _bstr_t with CString::Format()? Pin
Alvaro Mendez12-Dec-02 12:07
Alvaro Mendez12-Dec-02 12:07 
GeneralRe: _bstr_t with CString::Format()? Pin
Member 9612-Dec-02 13:03
Member 9612-Dec-02 13:03 
GeneralVolume Event or Notification Pin
Terry Denham12-Dec-02 11:20
Terry Denham12-Dec-02 11:20 
GeneralRe: Volume Event or Notification Pin
-Dy12-Dec-02 23:31
-Dy12-Dec-02 23:31 
Generalhelp Pin
imran_rafique12-Dec-02 9:59
imran_rafique12-Dec-02 9:59 
GeneralRe: help Pin
Alvaro Mendez12-Dec-02 10:28
Alvaro Mendez12-Dec-02 10:28 
GeneralRe: help Pin
Alvaro Mendez12-Dec-02 10:34
Alvaro Mendez12-Dec-02 10:34 
GeneralRe: help Pin
imran_rafique13-Dec-02 9:30
imran_rafique13-Dec-02 9:30 
GeneralSTUPID PROBLEM Pin
Sunnygirl12-Dec-02 9:15
Sunnygirl12-Dec-02 9:15 
GeneralRe: STUPID PROBLEM Pin
Alvaro Mendez12-Dec-02 9:26
Alvaro Mendez12-Dec-02 9:26 
GeneralRe: STUPID PROBLEM Pin
Sunnygirl12-Dec-02 9:30
Sunnygirl12-Dec-02 9:30 
GeneralRe: STUPID PROBLEM Pin
Alvaro Mendez12-Dec-02 9:41
Alvaro Mendez12-Dec-02 9:41 
GeneralRe: STUPID PROBLEM Pin
Sunnygirl12-Dec-02 9:52
Sunnygirl12-Dec-02 9:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.