write Function

Write data to a file.

Attention: This interface function is implemented only by MPLAB XC32 C compilers.

Include

<unistd.h>

Prototype

int write(int handle, void * buffer, size_t count);

Arguments

handle
handle (file descriptor) referring to an opened file
buffer
points to the storage location of data to be written
count
the number of characters to write

Return Value

If successful, write returns the number of characters actually written. A return value of -1 indicates an error, in which case errno should be set to indicate the type of error. Suitable values may be EBADF or EINVAL, among others.

Remarks

This function is implemented as a stub that must be completed to suite the application.

This is a helper function called by the Standard C Library function fflush().

If the actual space remaining on the disk is less than the size of the buffer, the function trying to write to the disk write fails and does not flush any of the buffer’s contents to the disk. If the file is opened in text mode, each linefeed character is replaced with a carriage return-linefeed pair in the output. The replacement does not affect the return value.

Default Behavior

As distributed, the parameters are passed to the host file system through the simulator. The return value is the value returned by the host file system.

Source File

write.c