Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!samsung!cs.utexas.edu!rutgers!rochester!kodak!ektools!randolph From: randolph@ektools.UUCP (Gary L. Randolph) Newsgroups: comp.lang.c Subject: Re: fscanf question Message-ID: <2365@ektools.UUCP> Date: 2 Jan 90 19:22:00 GMT References: <6983@ohstpy.mps.ohio-state.edu> Sender: randolph@ektools (Gary L. Randolph) Reply-To: randolph@ektools.UUCP (Gary L. Randolph) Organization: Eastman Kodak, Dept. 47, Rochester NY Lines: 30 In article <6983@ohstpy.mps.ohio-state.edu> SMITHJ@ohstpy.mps.ohio-state.edu writes: /Sorry if this has come up before but I'm puzzled as to why the following code /doesn't work. The fprintf works fine but nothing is read in by the fscanf. /#include ***********>you mean stdio.h, right? / /int main(void) /{ / FILE *stream; / char outstr1[]="Trying", outstr2[]="Hoping"; / char instr1[30], instr2[30]; / / stream = fopen("try2.gbk","w"); ***********>In the 'real' world, of course, you check that this worked. / fprintf(stream,"%-30s %-30s",outstr1,outstr2); / fclose(stream); / / stream = fopen("try2.gbk","r"); / fscanf(stream,"%-30s %-30s",instr1,instr2); **********>the minus sign says left justify the *output*, this is all that **********>is confusing your compiler. Take them out, and all is well. / fclose(stream); /} And I can't help it, WAR EAGLE!!!!!!!!!!!!!!!!!!!!!!!! Gary