fclose

  • fclose(fileid) allows to close the file corresponding to fileid
  • fclose('all') closes all opened files
  • fclose returns 1 if operation has been successful and 0 otherwise

Examples

> fileid = fopen('outputfile.txt','w')

	[fileid:3]

> fprintf(fileid,'%s','let''s output this...')

	[ans:20]

> fclose(fileid)

	[ans:1]

> fclose(fileid) % will return 0 as fileid is already closed

	[ans:0]

Resources

See also

fopen | fprintf