ecs140w016@deneb.ucdavis.edu (0000;0000018921;4000;250;215;ecs140w) (03/25/89)
I am having trouble with the output in a small program that I wrote to spit
out some data. I use the unix redirected output feature on the UNIX
command line (ie. > outfile). The problem is that "outfile" does not contain
the total output. In the sample program that I have included, I loop around
100 times and there should be 100 lines of output but I only end up
getting around 90 to 95 lines. Other code that I have written gives even less.
By the way, I have up loaded the program (and changed the header and _main to
main) to a UNIX machine and all the output is there. So I know that the
problem lies somewhere other than my code. If it makes any difference, I'm
running LSC 3.01p4 on a stock Mac+ w/ and external drive.
Does anyone know what is going on?
THANKS
#include <unix.h>
_main()
{
float a11, a12, a13, a21, a22, a23, a31, a32, a33;
float p0, p1, p2, pt0, pt1, pt2;
int i;
a11 = 0.0;
a12 = 0.4;
a13 = 0.0;
a21 = 2.0;
a22 = 0.0;
a23 = 0.6;
a31 = 3.2;
a32 = 0.0;
a33 = 0.0;
p0 = 10.0;
p1 = 0.0;
p2 = 0.0;
for (i = 1;i <= 100; i++)
{
pt0 = p0 * a11 + p1 * a12 + p2 * a13;
pt1 = p0 * a21 + p1 * a22 + p2 * a23;
pt2 = p0 * a31 + p1 * a32 + p2 * a33;
printf(" %d %1.8f %1.8f %1.8f",i,pt0, pt1, pt2);
if (pt0 != 0.0)
printf(" %1.8f %1.8f\n", pt1/pt0, pt2/pt0);
else
printf("\n");
p0 = pt0;
p1 = pt1;
p2 = pt2;
}
}
********************************************************************************
* *
* Masters of Trivial Pursuit show how trivial their lives are! *
* *
********************************************************************************ted@hpwrce.HP.COM ( Ted Johnson) (03/27/89)
How about throwing in an fflush() at the end of your program. Shouldn't be necessary, but you never know.... -Ted
pem@cadnetix.COM (Paul Meyer) (03/29/89)
[]
Your problem is very simple. You are defining "_main()"
instead of "main()" for your main program even though you are using
Stdio. Thus when your main program terminates, the Stdio finalization
stuff doesn't get done.
The moral of the story is, don't mess with the normal way the
system works unless you know what you're doing!
Paul Meyer pem@cadnetix.COM
Cadnetix Corp.
5775 Flatirons Pkwy. {uunet,boulder}!cadnetix!pem
Boulder, CO 80301 (303)444-8075x244