home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / recio213.zip / rput.c < prev    next >
C/C++ Source or Header  |  1995-09-05  |  2KB  |  47 lines

  1. /*****************************************************************************
  2.    MODULE: rput.c
  3.   PURPOSE: recio output functions
  4. COPYRIGHT: (C) 1994-1995, William Pierpoint
  5.  COMPILER: Borland C Version 3.1
  6.        OS: MSDOS Version 6.2
  7.   VERSION: 2.13
  8.   RELEASE: September 4, 1995
  9. *****************************************************************************/
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14.  
  15. #include "recio.h"
  16.  
  17. extern int _risready(REC *rp, int mode);
  18. extern int _rputc(REC *rp, int ch);
  19.  
  20. #define rcol(rp)    ((rp)->r_colno)
  21.  
  22. /****************************************************************************/
  23. void                         /* returns nothing                             */
  24.     rputrec(                 /* put end-of-record (newline) to stream       */
  25.         REC *rp)             /* record pointer                              */
  26. /****************************************************************************/
  27. {
  28.     if (_risready(rp, R_WRITE)) {
  29.         _rputc(rp, '\n');
  30.         rcol(rp)=0;
  31.         rfldno(rp)=0;
  32.         rrecno(rp)++;
  33.     }
  34. }
  35.  
  36. /****************************************************************************/
  37. char *                       /* return pointer to string                    */
  38.     dtoa(                    /* convert floating point number to string     */
  39.         double d,            /* number to convert                           */
  40.         char  *str,          /* string buffer to use                        */
  41.         int    dig)          /* number of significant digits                */
  42. /****************************************************************************/
  43. {
  44.     sprintf(str, "%.*G", dig, d);
  45.     return str;
  46. }
  47.