User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 428,058 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,522 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums

Diff between fread() and fgets()

Join Date: May 2008
Posts: 349
Reputation: Radical Edward has a spectacular aura about Radical Edward has a spectacular aura about Radical Edward has a spectacular aura about 
Rep Power: 3
Solved Threads: 59
Radical Edward's Avatar
Radical Edward Radical Edward is offline Offline
Posting Whiz

Re: Diff between fread() and fgets()

  #2  
May 15th, 2008
fgets reads a single line of characters, but fread reads a block of unidentified objects. fgets uses '\n' as a delimiter, but fread doesn't inspect any of the objects so it relies on a limit of the number of objects. If you're using fread to read string data, the only two significant differences are:
  1. fgets terminates the string with '\0', but fread does not
  2. fgets uses '\n' as a delimiter as well as an upper limit, but fread only uses an upper limit
If at first you don't succeed, keep on sucking until you do succeed.
Reply With Quote  
All times are GMT -4. The time now is 11:51 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC