Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!usc!apple!sun-barr!decwrl!sgi!mplevine@sbc2.sgi.com From: mplevine@sbc2.sgi.com (Marshall Levine) Newsgroups: comp.sys.amiga Subject: Re: C scanf question Summary: Correction to this guy's C syntax Message-ID: <38337@sgi.SGI.COM> Date: 19 Jul 89 22:45:31 GMT References: <19915@louie.udel.EDU> <20578@cup.portal.com> Sender: daemon@sgi.SGI.COM Distribution: na Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 30 In article <20578@cup.portal.com>, morris-ng@cup.portal.com (Yuklung Morris Ng) writes: > string to the file and you write "fprintf(file,"%s",line[80]);" what you are > ... should be "fprintf(file,"%s",&line);"... Actually, I believe it should be: fprintf(file,"%s",line); or, if you want to be verbose: fprintf(file,"%s",&line[0]); You are going to print characters until you hit a '\0', but you are starting at the memory location of the pointer to the string, rather than the string itself. No big deal, just one more core dump (or system crash)... -- Marshall Levine mplevine@sgi.com mplevine@phoenix.princeton.edu Advanced Systems Design, Silicon Graphics Inc. Department of Computer Science, Princeton University -- -- Marshall Levine mplevine@sgi.com mplevine@phoenix.princeton.edu Advanced Systems Design, Silicon Graphics Inc. Department of Computer Science, Princeton University