fwrite writes data into a file.
Return Value
n is the number of elements written.
Parameters
Identifies the file.
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) |
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