Bifalgorithm post · Computer science one · Closing Files

How should you close files in C?

How should you close files in C? (Computer science one · Closing Files) — "Once you are done processing a file, you should close it using the fclose() function…

Ideas in this flowchart

  • Après avoir traité un fichier, il faut le fermer.
  • La fermeture intervient une fois le traitement du fichier terminé.
  • Utiliser la fonction fclose(FILE *fp) pour fermer le fichier.
  • La fonction reçoit comme argument le pointeur FILE du fichier à fermer.
  • Fermer un fichier invalide peut provoquer une erreur ou une faute de segmentation.
  • Après sa fermeture, un fichier ne peut plus être lu ni écrit ; toute tentative constitue un comportement indéfini.
  • Ne pas fermer un fichier peut entraîner sa corruption.
Feed/

How should you close files in C?

No cover

Channel

Computer science one

1 page

"Once you are done processing a file, you should close it using the fclose() function:\n\nint fclose(FILE *fp);\n\nwhich takes a single argument, the FILE pointer of the file you wish to close. Closing an invalid file may result in an error or segmentation fault. In any case, after a file has been closed, it cannot be read from or written to, doing so is undefined behavior. Failure to close a file may result in a corrupted file."

Flowchart preview
👍
0
0 comments0 shares

Sign in to view and post comments.