resnicks@netcom.UUCP (Steve Resnick) (01/22/91)
In article <1991Jan21.154432.11941@cbnewsm.att.com> you write: > >Hi there people, > > A quick question, I am used to using c programming on a amdahl, but > also started working on msdos Turbo-c 1.5. I am having >problems with reading and writing to a file. I am using a structure of about >8 to 10 doubles in it. > > >struct empdata { > double wages; > double tariff; > .. > .. > > double netwages; >} EmpData; > >When I am writing and reading to a file, a lot of the time I get an fread error >19 invalid argument. I can figure it out. Does this have something to do >with using ptr=fopen("DATA","r+b"); . I have never seen "r+b" before, but maybe >that is the problem. could somebody explain this r+b and tell me if this is >my problem. > When using fopen(filename,"r+b") you are specifying that the file is to be opened for reading (and writing), (r specifies read, + specified the opposite of the first mode (r)) and b specifies it should be binary rather than text. Can you give an example of your fread statement? The fopen seems to be fine, unless the file doesn't exist. Cheers! Steve