home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / CLIB1.ZIP / SPRINTF.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  2.6 KB  |  87 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. /*|                                                              |*/
  12. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  13. /*|                                                              |*/
  14. /*|                                                              |*/
  15. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  16. /*|     All Rights Reserved.                                     |*/
  17. /*|                                                              |*/
  18. /*[]------------------------------------------------------------[]*/
  19.  
  20.  
  21. #include <stdio.h>
  22. #include <mem.h>
  23. #include <string.h>
  24. #include <_printf.h>
  25.  
  26. /*---------------------------------------------------------------------*
  27.  
  28. Name        strputn - copies an n element string
  29.  
  30. Usage        static size_t pascal strputn(char *S, size_t n,
  31.                          char **bufPP)
  32.  
  33. Description    copies n bytes from block pointed to by S to the block
  34.         pointed to by bufPP.  bufPP is incremented by n.
  35.  
  36. Return value    0
  37.  
  38. *---------------------------------------------------------------------*/
  39. static size_t pascal near strputn(char *S, size_t n, char **bufPP)
  40. {
  41.     memcpy (*bufPP, S, n);
  42.     *(*bufPP += n) = 0;
  43.     return n;
  44. }
  45.  
  46.  
  47. /*---------------------------------------------------------------------*
  48.  
  49. Name        sprintf - sends formatted output to a string
  50.  
  51. Usage        int sprintf(char *string, const char *format[, argument, ...]);
  52.  
  53. Prototype in    stdio.h
  54.  
  55. Description    sends formatted output to a string
  56.  
  57. Return value    number of bytes output
  58.  
  59. *---------------------------------------------------------------------*/
  60. int cdecl sprintf(char *bufP, const char *fmt, ...)
  61. {
  62.     *bufP = 0;
  63.     return    __vprinter ((putnF *)strputn, &bufP, fmt, (void _ss *) _va_ptr);
  64. }
  65.  
  66.  
  67.  
  68. /*---------------------------------------------------------------------*
  69.  
  70. Name        vsprintf - sends formatted output to a string
  71.  
  72. Usage        int vsprintf(char *string, const char *format, va_list param);
  73.  
  74. Prototype in    stdio.h
  75.  
  76. Description    sends formatted output to a string
  77.  
  78. Return value    number of bytes output
  79.  
  80. *---------------------------------------------------------------------*/
  81. int cdecl vsprintf(char *bufP, const char *fmt, va_list ap)
  82. {
  83.     *bufP = 0;
  84.     return    __vprinter ((putnF *)strputn, &bufP, fmt, (void _ss *) ap);
  85. }
  86.  
  87.