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).
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
- What Is #include?
- What Is Indexed File Organization?
- How The Performance Of Database?
- How Is That The Additional Hardware Affect The Data Base Management System?
- How Do You Automate Starting And Shutting Down Of Databases In Unix?
- How Design An Algorithm For The SIMD Computer To Calculate The Sum Of An Array (A) Of 8 Elements. Assume That Element Ai Is Stored In The Local Memory Of PEi, Where I=1,2,3,.......4?
- Do I Have To Write A Main Method In Every Class I Create?Why?
- Do I Have To Write A Main Method In Every Class I Create?
- What Is Centralize Database Management System?
- Why We Indicate FF As 0FF In Program?
- When To Apply For Css?
- How Do I Enable Java On My I465?
- What Are Key Features Of Procedural Programming?
- What Is Conceptual Methodology?
- What Is Hierarchy Or Structure Of Database?
- Explain How Records And Related Records Are Deleted To Ensure The Integrity?
- I Am Non IT Professionals And Now I Want To Join MS Dynamics CRM. I Learnt Tha C# And ASP.net Is Must For That?
- What Is The Definition Of Hierarchical?
- What Is Rule Based Query?
- A B C D E A B C D A B C A B A Search Program For This Output (using For Loop)?
- How To Convert Binary To Octal In Java Programming?
- What Is Overloading In Java?
- Why Relations Should Not Have Transitive Dependency. Illustrate With Example?
- Create A Program That Displays Color Of An Item Whose Item Number Is Entered By User In C++?
- What Compression Programs Are Associated With Zip Sit And Exe File Extensions?
- Can Anyone Explain The Usage Of 'Either'?
- Can You Explain The Usage And Step Of Literature Survey?
- Can You Explain The Functions Of Capital:
- Explain The Functions Of An Entrepreneur.
- Can Anyone Explain Different Functions Of Auditing?
- Can You Explain The Functions Of The Market?
- Can Anyone Explain The Different Functions Of A Trade Union?
- Can You Explain The Cytoskeleton Functions And Structure?

New Comment - Comments are editable for 5 min.