home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / fputs.c < prev    next >
C/C++ Source or Header  |  1998-06-17  |  1KB  |  59 lines

  1. /***
  2. *fputs.c - write a string to a stream
  3. *
  4. *       Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       defines fputs() - writes a string to a stream
  8. *
  9. *******************************************************************************/
  10.  
  11. #include <cruntime.h>
  12. #include <stdio.h>
  13. #include <dbgint.h>
  14. #include <file2.h>
  15. #include <string.h>
  16. #include <internal.h>
  17. #include <mtdll.h>
  18.  
  19. /***
  20. *int fputs(string, stream) - write a string to a file
  21. *
  22. *Purpose:
  23. *       Output the given string to the stream, don't write the '\0' or
  24. *       supply a '\n'.  Uses _stbuf and _ftbuf for efficiency reasons.
  25. *
  26. *Entry:
  27. *       char *string - string to write
  28. *       FILE *stream - stream to write to.
  29. *
  30. *Exit:
  31. *       Good return   = 0
  32. *       Error return  = EOF
  33. *
  34. *Exceptions:
  35. *
  36. *******************************************************************************/
  37.  
  38. int __cdecl fputs (
  39.         const char *string,
  40.         FILE *stream
  41.         )
  42. {
  43.         REG2 int buffing;
  44.         REG1 unsigned int length;
  45.         REG3 unsigned int ndone;
  46.  
  47.         _ASSERTE(string != NULL);
  48.         _ASSERTE(stream != NULL);
  49.  
  50.         length = strlen(string);
  51.         _lock_str(stream);
  52.         buffing = _stbuf(stream);
  53.         ndone = _fwrite_lk(string,1,length,stream);
  54.         _ftbuf(buffing, stream);
  55.         _unlock_str(stream);
  56.  
  57.         return(ndone == length ? 0 : EOF);
  58. }
  59.