Share via


_FWrite( ) API Library Routine

Writes exactly length bytes from your buffer to a file specified by chan.

unsigned int _FWrite(FCHAN chan, char FAR *buffer, int length)
FCHAN chan;               /* File channel of file to write to. */
char FAR *buffer;            /* Buffer address. */
int length;                  /* Number of bytes to write. */

Remarks

_FWrite( ) doesn't add a terminator to the file. No translation is performed on the bytes before they are written. _FWrite( ) returns the number of bytes written.

For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.

Example

The following example creates a test file and writes some data to it using _FWrite( ).

Visual FoxPro Code

SET LIBRARY TO FWRITE  

C Code

#include <pro_ext.h>

FAR Example(ParamBlk FAR *parm)
{
   FCHAN fchan;

   fchan = _FCreate("temp.tmp", FC_NORMAL);
   _FWrite(fchan, "Hello, world.", _StrLen("Hello, world."));
   _FWrite(fchan, "\xd\xa", 2);
   _FWrite(fchan, "1234567890", 10);
   _FClose(fchan);
}

FoxInfo myFoxInfo[] = {
   {"FWRITE", (FPFI) Example, CALLONLOAD, ""},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

See Also

_FFlush( ) API Library Routine | _FPuts( ) API Library Routine | _FSeek( ) API Library Routine | Accessing the Visual FoxPro API