Fclose

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 21:46, 30 January 2014
Smithy (Talk | contribs)

← Previous diff
Revision as of 23:58, 31 January 2014
Connor Mead (Talk | contribs)

Next diff →
Line 28: Line 28:
[[Category:Scripting Functions]] [[Category:Scripting Functions]]
[[Category:File Functions]] [[Category:File Functions]]
 +
 +[[fr:Fclose]]

Revision as of 23:58, 31 January 2014


Image:Farm-Fresh text lowercase.png Note: This function name starts with a lowercase letter.


Description:

Closes a file. Files should always be closed when the script no longer needs them (after reading/writing).


Parameters:
(File:handle)
File:handleThe file handle to close. Returned by fopen.


Return Values:

true (1) on success false (0) on failure.


Image:32px-Circle-style-warning.png

Important
Note

The file handle must be valid, and must point to a file successfully opened by fopen.


new File:example = fopen("Hello.txt", io_append); // Open 'Hello.txt' in the scriptfiles directory
if(example) // Check that it was successfully opened
{
    fwrite(example, "Hi there!"); // Write in the file
    fclose(example); // Close it
}

Related Functions

The following functions may be useful, as they are related to this function in one way or another.

In other languages