home *** CD-ROM | disk | FTP | other *** search
-
- /* Logitech MultiScope Debugger Tutorial Program
- * Copyright (C) 1989 Logitech, Inc.
- *
- * This is the second C module for TUTOR.C
- */
-
- #include <stdio.h>
- #include <malloc.h>
- #include <string.h>
- #include <os2def.h>
- #define INCL_DOS
- #include <bse.h>
-
-
- struct DataRec {
- struct DataRec far *left, far *right;
- int value;
- int uc;
- char dataString[129];
- } *root;
-
- int count;
-
- Insert(rec)
- struct DataRec *rec;
- {
- struct DataRec *p;
-
- rec->left = NULL;
- rec->right = NULL;
- rec->uc = 0;
- if (!root) {
- root = rec;
- return;
- }
- p = root;
- while (p) {
- if (rec->value < p->value) {
- if (p->left)
- p = p->left;
- else {
- p->left = rec;
- count++;
- return;
- }
- }
- else {
- if (rec->value > p->value) {
- if (p->right)
- p = p->right;
- else {
- p->right = rec;
- count++;
- return;
- }
- }
- else {
- rec->uc++;
- return;
- }
- }
- }
- }
-
- Print()
- {
- printf("Debuggers over history:\n");
- DoPrint(root);
- }
-
- DoPrint(p)
- struct DataRec *p;
- {
- if (p != NULL) {
- DoPrint(p->left);
- DoPrint(p->right);
- printf("%s\n",p->dataString);
- }
- }
-
- InitInsert()
- {
- root = NULL;
- }
-
-