Home TechnologyProgramming Subscribe to RSS

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

Answer Question

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  

    answered 2 years ago

      More

      More

         
         

        Ask a Question via Twitter

        Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

        Blurtit Store

        Get T-shirts, hoodies, caps and more at the Blurtit store

        Blurtit International