Shiny Language Reference

Language Reference > File Functions


fwritebytes

bool fwritebytes(file FileVar, string Source, int Bytes);

 

 

Writes a number of bytes to a file

The FWRITEBYTES statement writes the specified number of bytes to a file previously opened by FOPEN. No additional data is written to the file (eg: no linefeed), therefore this statement is useful for updating individual bytes or flags in a file.

 

Parameters

FileVar

A variable declared as type FILE which has previously been associated with a file by using FOPEN.

Source

The string (bytes) to write to the file

Bytes

The number of bytes that will be written. The Source parameter must be at least as long as this value. If the Source parameter has less bytes than is specified here, the entire Source string is written to the file. This is a safety mechanism to prevent buffer overflows.

 

Return Value

TRUE if writing suceeded, otherwise FALSE.

 

Example Code

file myfile;

if(fopen(myfile, "C:\\Readme.txt") == TRUE)
{
    string MyString = "Some data";

    fwritebytes(myfile, MyString, strlen(MyString));
}