home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 5.ddi / CLIBSRC2.ZIP / SPRINTF.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  2.4 KB  |  85 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - sprintf.c
  3.  *
  4.  * function(s)
  5.  *        strputn  - copies an n element string
  6.  *        sprintf  - sends formatted output to a string
  7.  *        vsprintf - sends formatted output to a string
  8.  *-----------------------------------------------------------------------*/
  9.  
  10. /*
  11.  *      C/C++ Run Time Library - Version 5.0
  12.  *
  13.  *      Copyright (c) 1987, 1992 by Borland International
  14.  *      All Rights Reserved.
  15.  *
  16.  */
  17.  
  18.  
  19. #include <stdio.h>
  20. #include <mem.h>
  21. #include <string.h>
  22. #include <_printf.h>
  23.  
  24. /*---------------------------------------------------------------------*
  25.  
  26. Name            strputn - copies an n element string
  27.  
  28. Usage           static size_t pascal strputn(char *S, size_t n,
  29.                                              char **bufPP)
  30.  
  31. Description     copies n bytes from block pointed to by S to the block
  32.                 pointed to by bufPP.  bufPP is incremented by n.
  33.  
  34. Return value    0
  35.  
  36. *---------------------------------------------------------------------*/
  37. static size_t pascal near strputn(char *S, size_t n, char **bufPP)
  38. {
  39.         memcpy (*bufPP, S, n);
  40.         *(*bufPP += n) = 0;
  41.         return n;
  42. }
  43.  
  44.  
  45. /*---------------------------------------------------------------------*
  46.  
  47. Name            sprintf - sends formatted output to a string
  48.  
  49. Usage           int sprintf(char *string, const char *format[, argument, ...]);
  50.  
  51. Prototype in    stdio.h
  52.  
  53. Description     sends formatted output to a string
  54.  
  55. Return value    number of bytes output
  56.  
  57. *---------------------------------------------------------------------*/
  58. int cdecl _FARFUNC sprintf(char *bufP, const char *fmt, ...)
  59. {
  60.         *bufP = 0;
  61.         return  __vprinter ((putnF *)strputn, &bufP, fmt, (void _ss *) _va_ptr);
  62. }
  63.  
  64.  
  65.  
  66. /*---------------------------------------------------------------------*
  67.  
  68. Name            vsprintf - sends formatted output to a string
  69.  
  70. Usage           int vsprintf(char *string, const char *format, va_list param);
  71.  
  72. Prototype in    stdio.h
  73.  
  74. Description     sends formatted output to a string
  75.  
  76. Return value    number of bytes output
  77.  
  78. *---------------------------------------------------------------------*/
  79. int cdecl _FARFUNC vsprintf(char *bufP, const char *fmt, va_list ap)
  80. {
  81.         *bufP = 0;
  82.         return  __vprinter ((putnF *)strputn, &bufP, fmt, (void _ss *) ap);
  83. }
  84.  
  85.