Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!ubvax!ardent!peck!rap From: rap@peck.ardent.com (Rob Peck) Newsgroups: comp.sys.amiga Subject: Re: C scanf question Message-ID: <7411@ardent.UUCP> Date: 20 Jul 89 16:53:36 GMT References: <19915@louie.udel.EDU> <20578@cup.portal.com> Sender: news@ardent.UUCP Reply-To: rap@peck.ardent.com (Rob Peck) Distribution: na Organization: Ardent Computer Corp., Sunnyvale, CA Lines: 20 In article <20578@cup.portal.com> morris-ng@cup.portal.com (Yuklung Morris Ng) writes: >RE: scanf() question: > >It seems to me that the fprintf() is the problem. When you try to print a >string to the file and you write "fprintf(file,"%s",line[80]);" what you are >writing is garbage. The program will try to write the string at address >&line + 80 and end with a \0 char. So the correct format should be >"fprintf(file,"%s",&line);"... ^^^^^ Looks like an "oops" in the correction. This should be "&line[0]" or just "line". The way the correction is written, the user would be writing X characters beginning at the memory location at which the pointer named 'line' was stored. Just couldn't let it get by. Rob Peck