View Single Post
Join Date: Oct 2008
Posts: 60
Reputation: Whilliam is an unknown quantity at this point 
Solved Threads: 0
Whilliam's Avatar
Whilliam Whilliam is offline Offline
Junior Poster in Training

Re: help about fread and fwrite

 
0
  #6
Nov 24th, 2008
Originally Posted by ArkM View Post
Is it so hard job to correct obvious errors: you get compiler messages on wrong function arguments: fread and fwrite want POINTERS to target/source data areas (&d - not d, &b - not b))!

Use code tag properly:
[code=c]
source
[/code]

Never use dangerous gets function: it does not check target buffer size. Use fgets instead of gets:
  1. fgets(fn,sizeof fn,sdtin);
With gets you program crashed if the file name length is greater than 49.

Don't forget to append carriage return:
  1. printf("\nFile saved\n");

Avoid using of non-standard function flushall().
thanks ArkM. Now I can do storing and getting data from files with integers and floats. Thanks for the tips too. I'm really slow. It's hard for me to solve obvious errors that I haven't encountered before..
Last edited by Whilliam; Nov 24th, 2008 at 7:19 am.
Reply With Quote