Write binary data to a file
UInt_Type fwrite (b, File_Type fp)
The fwrite may be used to write the object represented by
b to an open file. If b is a string or an array, the
function will attempt to write all elements of the object to the
file. It returns the number of objects successfully written,
otherwise it returns -1 upon error and sets errno
accordingly.
The following example illustrates how to write an integer array to a
file. In this example, fp is an open file descriptor:
variable a = [1:50]; % 50 element integer array
if (50 != fwrite (a, fp))
error ("fwrite failed");
Here is how to write the array one element at a time:
variable a = [1:50];
foreach (a)
{
variable ai = ();
if (1 != fwrite(ai, fp))
error ("fwrite failed");
}
Not all data types may support the fwrite operation. However,
it is supported by all vector, scalar, and string objects.
- slangrtl
-
clearerr,
fclose,
fdopen,
feof,
ferror,
fflush,
fgets,
fgetslines,
fileno,
fopen,
fprintf,
fputs,
fread,
fseek,
ftell,
isatty,
mkdir,
open,
pack,
pad_pack_format,
popen,
printf,
read,
sizeof_pack,
sscanf,
uname,
unpack,
write
|