fwrite¶
fwrite writes data into a file.
- n = fwrite(fh, ssType, dat)
- n = fwrite(fh, dat)
- n = fwrite_char(fh, dat)
- n = fwrite_char8(fh, dat)
- n = fwrite_float64(fh, dat)
- n = fwrite_float32(fh, dat)
- n = fwrite_int8(fh, dat)
- n = fwrite_uint8(fh, dat)
- n = fwrite_int16(fh, dat)
- n = fwrite_uint16(fh, dat)
- n = fwrite_int32(fh, dat)
- n = fwrite_uint32(fh, dat)
- n = fwrite_int64(fh, dat)
- n = fwrite_uint64(fh, dat)
Return Value
n is the number of elements written.
Parameters
- fh
Identifies the file.
- ssType
ssType is one of the following strings:
Value |
Meaning |
---|---|
“double” |
(8 Bytes) |
“real48” |
(6 Bytes) |
“float” |
(4 Bytes) |
“char” |
(1 Bytes) |
“char8” |
(1 Bytes) |
“uchar” |
(1 Bytes) |
“int” |
(4 Bytes) |
“uint” |
(4 Bytes) |
“long” |
(4 Bytes) |
“ulong” |
(4 Bytes) |
“short” |
(2 Bytes) |
“ushort” |
(2 Bytes) |
- dat
Example
fh = fopen("/test.bin", "w");
rvValues = 1:100; // 1,2,3,4,...
fwrite(fh, "short", rvValues); // writes 100 short values
fclose(fh);
fh = fopen("/test.bin", "r");
rvValues = fread(fh, "short", 100); // reads 100 short values
fclose(fh);
History
Version |
Description |
---|---|
5.9.0 |
New type “char8”. |
See also
id-630344