On Sat, 21 Mar 1998, David E. Fox wrote:

> > The second argument to scanf in the line
> > 
> >   scanf("%s", &filename);
> > 
> > needs to be a pointer to a char ARRAY large enough to hold the input.  The
> > way it is, you are overwriting memory.  The fact that is works on digital
> > unix is just a fluke.
> 
> Not only that, if filename is defined as a pointer to char, then that
> & in there is spurious, and he's doing an extra unwanted dereference, and
> as such will really be overwriting memory he doesn't want to be. :)

True.  I didn't bother reposting his entire code, in which he has filename
defined as simply char.  I assumed he would know enough to remove the &
when redefining filename as an array.  But perhaps I shouldn't make such
assumptions. =)

   Michael

---------------------------------------------------------------------
DISCLAIMER: All opinions expressed herein are my own and should not
be construed to represent those of Washington University or any other
organization.
---------------------------------------------------------------------
Michael P. Plezbert                             [EMAIL PROTECTED]
Graduate Student                   http://www.cs.wustl.edu/~plezbert/
Department of Computer Science
Washington University in St. Louis


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com/RedHat-FAQ /RedHat-Errata /RedHat-Tips /mailing-lists
         To unsubscribe: mail [EMAIL PROTECTED] with 
                       "unsubscribe" as the Subject.

Reply via email to