fwrite

fwrite schreibt Daten in eine Datei.

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)

Returnwert

n ist die Anzahl der Elemente, die geschrieben wurden.

Parameter

fh

fh ist ein Datei-Zugriffsnummer (file handle), die die Funktion fopen erzeugt hat.

ssType

ssType ist eine der folgenden Zeichenketten:

Wert Bedeutung
„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

Beispiel

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 Beschreibung
5.9.0 Neuer Typ „char8“.

id-630344