🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2328

Re: a problem with printf

#2328
From: walter briscoe
Date: Mon, 18 Mar 1996 13:50
88 lines
2830 bytes
OOPS!  I got the message garbled.  I had also got irritated with nothing
appearing for several days and then it did and it was rubbish.  I shall
translate and attempt correction.

In article <4i7vpu$432@solutions.solon.com>
           walter@wbriscoe.demon.co.uk "walter briscoe" writes:

 > In article <4i6hn8$pc9@solutions.solon.com> motte@ens.lifl.fr  writes:
 > 
 > > Hello,
 > > 
 > > I post the code as you asked me.
 > > The problem is in the main function.
 > > Now it does not run but if I let the line impr(essai) it does run very well.
 > > If you do not find the solution, do not worry, my teacher could not solve
 > > this problem.
 > > 
 > > thanks.
 > > 
 > > 
 > > PS : sorry, but I do not speak english very well.
 > > ----------
 > 
 > Meiux que je parle francais. J'ai essaye pc-lint. Il a trouve

Better than I speak French, pv-lint found:

 >
 > [snip]
 > 
 > > void echanger ( fichier *f1, fichier *f2 )
 > > {
 > >   fichier *tmp;
 > >   *tmp=*f1; /* tmp n'indique rien ici */
 > >   *f1=*f2;
 > >   *f2=*tmp;
 > > }
 > 
 > j'ai essaye
 > 
 > void echanger ( fichier *f1, fichier *f2 )
 > {
 >   fichier *tmp;
 >   tmp=*f1;
 >   *f1=*f2;
 >   *f2=tmp;
 > }
 > 
 > Tout sera bien.
 > 

I replaced the first version of echanger with the following rather than
the second as indicated:

void echanger ( fichier *f1, fichier *f2 )
{
  fichier tmp;
  tmp=*f1;
  *f1=*f2;
  *f2=tmp;
}

Everything was fine - my French said will be but I'm sure you
understand. The original version trashes an arbitrary section of memory.
That was enough to crash my DOS machine and did not do much good either
on the original box.

 > Il y a aussi:
 > 
 > void echanger ( fichier *f1, fichier *f2 )
 > {
 >   fichier *tmp;
 >   tmp=f1;
 >   f1=f2;
 >   f2=tmp;
 > }
 > 
 > Mais, ca fait rien!!
 > 

I went on to show a third version which is nonsense because it moves
things about without affecting the external environment.  Neither my
compiler nor pc-lint noticed.

 > I would be interested in a tool which would detect the problem in the
 > third version of "echanger".  Pc-lint/Flexelint do not.
--
walter briscoe
Technical Details
Message-ID: <4ijpnr$1ha@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4i6hn8$pc9@solutions.solon.com> <4i7vpu$432@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: walter briscoe <walter@wbriscoe.demon.co.uk>
Newsgroups: comp.lang.c.moderated
Subject: Re: a problem with printf
Date: 18 Mar 1996 07:50:51 -0600
Organization: Digital Solutions
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4ijpnr$1ha@solutions.solon.com>
References: <4i6hn8$pc9@solutions.solon.com> <4i7vpu$432@solutions.solon.com>
Reply-To: walter@wbriscoe.demon.co.uk
NNTP-Posting-Host: solutions.solon.com
X-NNTP-Posting-Host: wbriscoe.demon.co.uk
X-Newsreader: Demon Internet Simple News v1.30
X-Mail2News-Path: wbriscoe.demon.co.uk