home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 18746 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  1.2 KB

  1. Path: sparky!uunet!spool.mu.edu!olivea!charnel!sifon!thunder.mcrcim.mcgill.edu!mouse
  2. From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What should be returned by the functions...???
  5. Message-ID: <1992Dec21.173938.19490@thunder.mcrcim.mcgill.edu>
  6. Date: 21 Dec 92 17:39:38 GMT
  7. References: <BzKoIM.L3@cs.uiuc.edu>
  8. Organization: McGill Research Centre for Intelligent Machines
  9. Lines: 25
  10.  
  11. In article <BzKoIM.L3@cs.uiuc.edu>, ctaylor@cs.uiuc.edu (Conrad Taylor) writes:
  12.  
  13. > What should the functions, insertright and insertleft, return because
  14. > I'm receiving errors with Borland C++ 3.1.  For exmaple, functions
  15. > isn't returning a value.
  16.  
  17. [all but control structure removed -dM]
  18. > NODEPTR insertright(NODEPTR p, int x)
  19. > {
  20. >   if (p == NULL) {
  21. >      return;
  22. >      } /* end if */
  23. >   return;
  24. > } /* end insertright */
  25.  
  26. You declared it as returning NODEPTR but aren't returning anything.
  27. The compiler is quite correct to get upset; if you declare a function
  28. as returning a type, you really need to return a value of that type.
  29. If you don't have mean for it to return anything, then declare it as
  30. returning void.
  31.  
  32.                     der Mouse
  33.  
  34.                 mouse@larry.mcrcim.mcgill.edu
  35.