home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / CLIB1.ZIP / PUTW.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  1.7 KB  |  48 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - putw.c
  3.  *
  4.  * function(s)
  5.  *        putw - puts word on a stream
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*[]------------------------------------------------------------[]*/
  9. /*|                                                              |*/
  10. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  11. /*|                                                              |*/
  12. /*|                                                              |*/
  13. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  14. /*|     All Rights Reserved.                                     |*/
  15. /*|                                                              |*/
  16. /*[]------------------------------------------------------------[]*/
  17.  
  18. #include <stdio.h>
  19.  
  20. /*---------------------------------------------------------------------*
  21.  
  22. Name            putw - puts a character or word on a stream
  23.  
  24. Usage           #include <stdio.h>
  25.                 int putw(int w, FILE *stream);
  26.  
  27. Prototype in    stdio.h
  28.  
  29. Description     putw outputs the integer w to the output stream. putw neither
  30.                 expects nor causes special alignment in the file.
  31.  
  32. Return value    On success putw returns the integer w.
  33.  
  34.                 On error, putw returns EOF.
  35.  
  36.                 Since EOF is a legitimate integer, ferror
  37.                 should be used to detect errors with putw.
  38.  
  39. *---------------------------------------------------------------------*/
  40. int putw(int w, FILE *fp)
  41. {
  42.     if (putc(*((unsigned char *)&(w)), fp) != EOF)
  43.         if (putc(*((unsigned char *)&(w) + 1), fp) != EOF)
  44.                         return(w);
  45.  
  46.         return EOF;
  47. }
  48.