home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c
- Path: sparky!uunet!decwrl!mips!tsoft!dennis
- From: bbs.dennis@tsoft.sf-bay.org (Dennis Yelle)
- Subject: can I call vprintf() twice in a row?
- Message-ID: <ZJ2FoB1w165w@tsoft.sf-bay.org>
- Sender: bbs@tsoft.sf-bay.org (BBS User)
- Organization: The TSoft BBS and Public Access Unix, +1 415 969 8238
- Date: Sat, 25 Jul 1992 01:19:58 GMT
- Lines: 39
-
- #if 0
- Is the following legal ansi c?
- I beleave that it is, but if not, I would like to know why not.
- Note in particular that vprintf() is called twice in a row.
- I just discovered a vprintf() that changes arg_ptr when
- I do this, causing the second vprintf to fail.
- In case you are wondering, the bad vprintf() came from Watcom.
- #endif
-
- /* --------- cut here for vfpf.c -------------------- */
-
- #include <stdarg.h>
- #include <stdio.h>
-
- void report( char *fmt, ...)
- {
- va_list arg_ptr;
-
- va_start( arg_ptr, fmt);
- vprintf( fmt, arg_ptr);
- vprintf( fmt, arg_ptr); /* Yes, we want to print it twice. */
- /* In the original program, the second */
- /* was vfprintf to a log file. */
- va_end( arg_ptr);
- }
-
- main( int argc, char **argv)
- {
- int a;
-
- for( a=0; a<argc; a++) {
- report( "arg %d is %s\n", a, argv[a]);
- }
- return 0;
- }
- /* --------- cut here for vfpf.c -------------------- */
-
- --
- Dennis Yelle (bbs.dennis@tsoft.sf-bay.org)
-