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

  1. Path: sparky!uunet!sun-barr!ames!network.ucsd.edu!jracine
  2. From: jracine@weber.ucsd.edu (Jeff Racine)
  3. Newsgroups: comp.lang.c
  4. Subject: printf() waiting for loop(s) to finish - how to override...
  5. Date: 2 Sep 1992 04:44:25 GMT
  6. Organization: University of California, San Diego
  7. Lines: 39
  8. Distribution: world
  9. Message-ID: <181gr9INNle8@network.ucsd.edu>
  10. NNTP-Posting-Host: weber.ucsd.edu
  11. Summary: Some compilers do, some don't...
  12. Keywords: printf(), waiting for loop finish, gcc and cc _but_ not ztc, bcc.
  13.  
  14. When I compile a program with the following code on an HP system using
  15. cc or using gcc (both on the HP or under MessDOS) the following
  16. printf() statement only prints after both loops are finished. Since
  17. the statement tells me where in the total number of replications the
  18. program currently is, this depeats the purpose of the statement!
  19.  
  20. This does not happen when the program is compiled with bcc or ztc
  21. (Borland or Zortech). 
  22.  
  23. Question: Is there a (simple) way to override this delayed screen I/O?
  24.  
  25. Here is the offending code (if it is of any use). Thanks in advance
  26. for any help or pointers.
  27.  
  28. ------------------------------------------------------------------
  29.         for(i = 0; i < num_cv_rep; i++) {
  30.  
  31.           printf("\rReplication %d", i+1); /* non-executing statement */
  32.  
  33.           fprintf(File11,"%f\t", mker_ne(x, scale_fac, num_va, num_ob));
  34.  
  35.           for(m=0; m < num_va; m++) {
  36.             fprintf(File11,"%f\t", scale_fac[m]);
  37.             scale_fac[m] += inc_flt;
  38.           }
  39.  
  40.           fprintf(File11, "\n");
  41.  
  42.         }
  43. -----------------------------------------------------------------
  44. p.s. the function mker_ne() is a computationally intensive function
  45. and may take, say, 20 seconds to execute - I wish to execute the
  46. function with different values of scale_fac, say, 100 different
  47. values. Thus the value in knowing where the program is at.
  48. -- 
  49. -----------------------------------------------------------------------------
  50. Jeff Racine        
  51. jracine@weber.ucsd.edu
  52. racine@nexus.yorku.ca
  53.