home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18710 < prev    next >
Encoding:
Text File  |  1992-12-21  |  1.5 KB  |  70 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!ames!sun-barr!cs.utexas.edu!sdd.hp.com!ux1.cso.uiuc.edu!cs.uiuc.edu!sparc0b!ctaylor
  3. From: ctaylor@cs.uiuc.edu (Conrad Taylor)
  4. Subject: What should be returned by the functions...???
  5. Message-ID: <BzKoIM.L3@cs.uiuc.edu>
  6. Sender: news@cs.uiuc.edu
  7. Organization: University of Illinois at Urbana-Champaign
  8. Date: Sun, 20 Dec 1992 19:23:09 GMT
  9. Lines: 59
  10.  
  11.  
  12.     What should the functions , insertright and insertleft, return because
  13. I'm receiving errors with Borland C++ 3.1.  For exmaple, functions isn't
  14. returning a value.  Thanks in advance to all that reply.
  15.  
  16. -Con
  17.  
  18. ps: My e-mail is ctaylor@silver.lcs.mit.edu or
  19.     taylor1@wse.eecs.uic.edu. 
  20.  
  21.  
  22. struct node {
  23.    int info;
  24.    struct node *left;
  25.    struct node *right;
  26. };
  27.  
  28. typedef struct node *NODEPTR;
  29.  
  30. NODEPTR insertright(NODEPTR p, int x); /* ins immediately to right of header */
  31. NODEPTR insertleft(NODEPTR p, int x);  /* ins to the left of header          */
  32.       
  33. NODEPTR insertright(NODEPTR p, int x)
  34. {
  35.   NODEPTR q, r;
  36.  
  37.   if (p == NULL) {
  38.      printf("void insertion\n");
  39.      return;
  40.      } /* end if */
  41.   q = getnode();
  42.   q->info = x;
  43.   r = p->right;
  44.   r->left = q;
  45.   q->right = r;
  46.   q->left = p;
  47.   p->right = q;
  48.   return;
  49. } /* end insertright */
  50.  
  51. NODEPTR insertleft(NODEPTR p, int x)
  52. {
  53.   NODEPTR q, r;
  54.  
  55.   if (p == NULL) {
  56.      printf("void insertion\n");
  57.      return;
  58.      } /* end if */
  59.   q = getnode();
  60.   q->info = x;
  61.   r = p->left;
  62.   r->right = q;
  63.   q->left = r;
  64.   q->right = p;
  65.   p->left = q;
  66.   return;
  67. } /* end insertleft */
  68.  
  69.  
  70.