Chapter Contents

Previous

Next
afwrite0

afwrite0



Write a Record (possibly length 0)

Portability: SAS/C extension


SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTION
DIAGNOSTICS
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <lcio.h>

int afwrite0(const void *ptr, size_t size, size_t count, FILE *f);


DESCRIPTION

afwrite0 writes items from the stream associated with the FILE object addressed by f and then forces a record break. size defines the size of each item, count defines the maximum number of items to be written, and ptr addresses the area containing the items. If all the items do not fit into the current record, a diagnostic message is generated and the file's error flag is set. A call with a count of zero causes a zero-length record to be written, if the output file supports it.

Calls to afwrite0 to write items of type typeval commonly have the form

typeval buf[count];
numwrit = afwrite0(buf, sizeof(typeval), count, f);

afwrite0 is supported only for binary streams. See Augmented Standard I/O for more information on afwrite0 .

Note:    afwrite0 differs from afwrite only in the type of the return value and the treatment of a zero count .  [cautionend]


RETURN VALUE

afwrite0 returns the number of items written. If an error occurs, a negative value is returned.


CAUTION

When used on a file with relative attributes, afwrite0 behaves exactly like fwrite because these files are processed as continuous streams of characters without record boundaries. To process a file with relative attributes on a record-by-record basis, you must open it with afopen and specify the "seq" access method.


DIAGNOSTICS

afwrite0 never writes more than a single record; an error occurs if there is no room in the current record for all items.


EXAMPLE

See the example for afread0 .


RELATED FUNCTIONS

afwrite


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.