_putw

Description

Writes an integer to a stream.

#include <stdio.h>

int _putw( int binint, FILE *stream );

binint Binary integer to be output  
stream Pointer to FILE structure  

Remarks

The _putw function writes a binary value of type int to the current position of stream. The _putw function does not affect the alignment of items in the stream, nor does it assume any special alignment.

The _putw function is provided primarily for compatibility with previous libraries. Note that portability problems may occur with _putw, since the size of an int and ordering of bytes within an int differ across systems.

Return Value

The _putw function returns the value written. A return value of EOF may indicate an error. Since EOF is also a legitimate integer value, ferror should be used to verify an error.

Compatibility

Standards:UNIX

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:DOS32X

Use _putw for compatibility with ANSI naming conventions of non-ANSI functions. Use putw and link with OLDNAMES.LIB for UNIX compatibility.

See Also

_getw

Example

/* PUTW.C: This program uses _putw to write a word to a stream,

* then performs an error check.

*/

#include <stdio.h>

#include <stdlib.h>

void main( void )

{

FILE *stream;

unsigned u;

if( (stream = fopen( "data.out", "wb" )) == NULL )

exit( 1 );

for( u = 0; u < 10; u++ )

{

_putw( u + 0x2132, stdout );

_putw( u + 0x2132, stream ); /* Write word to stream. */

if( ferror( stream ) ) /* Make error check. */

{

printf( "_putw failed" );

clearerr( stream );

exit( 1 );

}

}

printf( "\nWrote ten words\n" );

fclose( stream );

}

Output

2!3!4!5!6!7!8!9!:!;!

Wrote ten words