beautypg.com

Fclose() – Echelon i.LON SmartServer 2.0 User Manual

Page 250

background image

236

Appendix A - Programmer’s Reference


if((pFile = fopen(Filename,"a")) == NULL)
{

printf(“Can't open or create i.LON 100 file = %s \n",
Filename);

}
else
{

fwrite(buf,1,len,pFile);
fclose(pFile);
printf("Wrote %d bytes to file = %s \n", len, Filename);

}

fclose()

You can use the fclose()method to close a file.

SYNTAX

int fclose (FILE * stream);

The stream parameter specifies a pointer to a FILE object

that specifies the file stream to be

closed.

If the file has been closed successfully, this method returns a zero value. Otherwise, it returns
EOF

(End-of-File).

EXAMPLE

The following example demonstrates an fclose()method that closes a file stream.

FILE * pFile;

fclose (pFile)