Home TechnologyProgramming

What is Blurtit?

Can You Explain The Usage Of The Following Liabrary Functions:1.fopen 2.fflush 3.fclose 4.fgets?

Fopen 2.fflush 3.fclose 4.fgets

1 Answer - Sort by: Date | Rating

    These are file functions.

    fopen takes the name of a file and how to open it (read-only, append, etc).  It returns a file handle.

    fclose closes a file handle.

    fflush pushes buffered data to the file.  This can be important if your OS delays writes to files for performance reasons.

    fgets reads a line from a file handle.

    For example, you might do this (in PHP):

    $fh = fopen('myfile.txt','r');
    $line = fgets($fh);
    fclose($fh);

    Error-checking is left as an exercise for the reader!

    You don't need to use fflush unless you are writing to the file handle (with fputs for example).
    1 0
    MadBiker

    MadBiker

    answered 2 years ago

      Answer Question - Answers are editable for 5 min.

      If you do not Sign-in or Register your answers will be anonymous,

      your answers may also be checked before going online.

       
       

      © 2007-2009 Blurtit