fflush

Flush buffered output to fileID to be written the file.

Syntax

R = fflush(fileID)

Inputs

fileID
File ID returned from an earlier call to fopen.
Type: double | integer

Outputs

R
Returns 0 on success and an error message is output on an error.
Type: integer

Example

Simple fflush example:


fileID = fopen('testfile', 'w+')
fwrite_result = fwrite(fileID, 15123, 'uint')
fflush_result = fflush(fileID)
frewind_result = frewind(fileID)
fread(fileID) % fread with no format specified
frewind_result = frewind(fileID)
fread(fileID, inf, 'unsigned int')  % fread with format specified
fclose_result = fclose(fileID)
fileID = 6
fwrite_result = 1
fflush_result = 0
frewind_result = 0
ans = [Matrix] 4 x 1
19
59
 0
 0
frewind_result = 0
ans = 15123
fclose_result = 0