aboutsummaryrefslogtreecommitdiff
path: root/sys/libc/putw.c
blob: d5cf6d8a2115bffe64945f09e25f7b452fe1a2b7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
*/

#define	import_spp
#define	import_libc
#define	import_stdio
#include <iraf.h>

/* PUTW -- Put a word (integer) to the output stream.  When used in conjunction
** with GETW this permits storage and retrieval of binary words to any file,
** albeit somewhat inefficiently.
*/
int
putw (
  int	word,			/* data word to be output	*/
  FILE	*fp			/* output file			*/
)
{
	register char	*ip;
	register int	n = sizeof (int);


	for (ip=(char *)&word;  --n >= 0;  ip++)
	    putc (*ip, fp);

	return (ferror(fp) ? EOF : word);
}