Novic C programmer needs help
Steve Watt
steve at wattres.UUCP
Tue Feb 13 19:36:06 AEST 1990
In article <1990Feb12.201406.215 at wam.umd.edu+ dkim at wam.umd.edu (Daeshik Kim) writes:
+ In article <1153 at psc90.UUCP> pyr201 at .UUCP (d^2) writes:
++ char *form (va_alist)
[ strange header ]
++ FILE b;
+
+ Why isn't this "File *b;" ?
I believe this is because the FILE structure is being used to fake out the
putchar's that are called in doprnt.
+
++ va_start (pvar);
++ fmt_string = va_arg (pvar, char*);
++
++ b._flag = _IOWRT|_IOSTRG;
++ b._ptr = result;
++ b._cnt = LINELEN;
++
++---> _doprnt(fmt_string, pvar, &b); <---
+ File b seems to be opended here.
File b is actually "opened" where b._flag =... happens. The thing that this
code is interested in is that b._ptr = result, the buffer to put the result
from doprnt into.
++ putc('\0', &b);
/* Put a null terminator on result */
++
++ va_end (pvar);
++ return (result);
++}
+
+ Where File b is closed?
+ What is this file?
+ I have not seen the whole program but either '_doprnt()' does
+ something wrong or file 'b' better to be closed with 'fclose()'.
+ Just an opinion!
+--
+ Daeshik Kim H: (301) 445-0475/2147 O: (703) 689-5878
+ SCHOOL: dkim at wam.umd.edu, dskim at eng.umd.edu, mz518 at umd5.umd.edu
+ WORK: dkim at daffy.uu.net (uunet!daffy!dkim)
#if defined(FLAME) && FLAME >= 0
The entire piece of code, however, is *awful*!!!!!! If there is a varargs
package around, there tends to be a vsprintf around! vsprintf is the very
correct way of doing this sort of thing. Depending on having _doprnt around
is NOT NICE!
#endif
--
Steve Watt
...!claris!wattres!steve wattres!steve at claris.com is reported to work.
Is rm -rf a way to remove high-frequence noise? (No names mentioned! :-)
More information about the Comp.lang.c
mailing list