home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / c / 12977 < prev    next >
Encoding:
Internet Message Format  |  1992-08-30  |  1.4 KB

  1. Path: sparky!uunet!ferkel.ucsb.edu!ucsbcsl!network.ucsd.edu!usc!cs.utexas.edu!asuvax!ennews!envmsa.eas.asu.edu!ptran
  2. From: ptran@envmsa.eas.asu.edu (Phi-Long Tran)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Kwik escape from recursive loop, Possible?
  5. Message-ID: <29AUG199221255122@envmsa.eas.asu.edu>
  6. Date: 30 Aug 92 04:25:00 GMT
  7. References: <1992Aug29.221941.20788@eng.ufl.edu>
  8. Sender: news@ennews.eas.asu.edu (USENET News System)
  9. Distribution: usa
  10. Organization: Arizona State University, Tempe, AZ
  11. Lines: 23
  12. News-Software: VAX/VMS VNEWS 1.4-b1
  13.  
  14. In article <1992Aug29.221941.20788@eng.ufl.edu>, 
  15. zzang@whale.uucp (Zhuo Zang[~{j0WA~}]) writes...
  16.  
  17. > I am writing a program.  In the program, I use a 'while (c!=EOF)'
  18. > statement to write char.  I also have a recursive call to get input char
  19. > in the program, this caused problem. the recursive call piles up a huge
  20. > stack when the c finally reaches the EOF; then it returns one by one, so
  21. > my output file ended with many(48 in one eg.)  EOF's (the 0xff in DOS).
  22.  
  23.      Does the input routine have to be recursive?  If possible, find an
  24. iterative solution.
  25.  
  26. > my question is:  is it possible to escape from the loop immediately
  27. > without returning the garbages once c reaches the EOF ?
  28.  
  29.      Look up the documentation for the functions "setjmp" and "longjmp" in
  30. the C library (I think the names are correct).  They allow you to perform
  31. non-local GOTO's.
  32.  
  33. ---
  34. Phi-Long Tran
  35. ptran@asuvax.eas.asu.edu
  36. Arizona State University
  37.