Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!nstn.ns.ca!news.cs.indiana.edu!samsung!zaphod.mps.ohio-state.edu!usc!jarthur!nntp-server.caltech.edu!tll From: tll@nntp-server.caltech.edu (Tal Lewis Lancaster) Newsgroups: comp.sys.amiga.programmer Subject: Re: SAS C Bug?? Standard FILE command does not work!! Message-ID: <1991Jan28.173003.2444@nntp-server.caltech.edu> Date: 28 Jan 91 17:30:03 GMT References: <1991Jan27.221835.1230@rodan.acs.syr.edu> Organization: California Institute of Technology, Pasadena Lines: 37 ben@epmooch.UUCP (Rev. Ben A. Mesander) writes: >>In article <1991Jan27.221835.1230@rodan.acs.syr.edu> goldberg@rodan.acs.syr.edu (Ross Goldberg) writes: >>I am trying to get a procedure working to read and write records to the >>disk. This is accomplished in many books by using fwrite and fread. >>The sample below comes from one of the books...the problem is: >[...] >>#include >>main () >>{ >> typedef struct { >> char name[15]; >> int midterm; >> } grades; >>int i,number; >>char name[50]; >>grades student; >>FILE *fp; >>printf("class file "); >>scanf("%s",name); >>if (NULL!=(fp=fopen(name,"w"))) { >> printf("number of students"); >> scanf("%d",&number); >> for (i=0;i> printf("student's name: "); >> scanf("%[^\n]",student.name); This doesn't answer your problem with fwrite. But it may interest you to know that SAS's scanf doesn't support %[]. >> printf("midterm score: "); >> scanf("%d",&(student.midterm)); >> fwrite (&student,sizeof(student),1,fp); > ^^^^^^ ^^^^^^^^ >> } [Rest deleted]