Strange C Program

Doug Gwyn gwyn at brl-smoke.ARPA
Thu Feb 25 20:23:05 AEST 1988


In article <238 at mccc.UUCP> pjh at mccc.UUCP (Peter J. Holsberg) writes:
>generates "EMT trap - core dumped" message, but when run by ROOT, it
>works like a charm!  Help!!
>     of = fopen("random", "w");
>       fprintf(of, "%11d",fseed);

Really, posting to the net is an expensive (to others!) way to do
your debugging.  The only reason I'm responding is to make the point
that the total absence of any error checking in your code has made
it extremely non-robust.  My suspicion is that for some reason you're
not able to create the file "random" for writing (perhaps there is
already one present owned by "root" and not publicly writable?).
The use in fprintf() of the NULL `of' value that you should have
checked for right after the fopen() can have strange results.

You should learn how to use the debugger(s) on your system; in
particular a function call traceback would show whether or not
the problem occurred inside fprintf(), and it would also show
what arguments the function received.



More information about the Comp.lang.c mailing list