home *** CD-ROM | disk | FTP | other *** search
-
- #include <stdarg.h>
-
- static doprnt(ofunct, funct_arg, fmt, argp)
- int (*ofunct)();
- char *funct_arg;
- char *fmt;
- va_list *argp;
- {
- /* A doprnt() for ANSI */
- /* (c) Copyright 1987, Allen I. Holub. */
-
- char buf[133], *p ;
-
- vsprintf( buf, fmt, argp );
- for( *p = buf; *p; (*ofunct)( *p++, funct_arg ) )
- ;
- }
-
- Example 1: A doprnt() for ANSI
-
-
-
-
- #include <varargs.h>
-
- static doprnt(ofunct, funct_arg, fmt, argp)
- int (*ofunct)();
- char *funct_arg;
- char *fmt;
- va_list argp;
- {
- /* A doprnt() for Unix. */
- /* (c) Copyright 1987, Allen I. Holub. */
-
- int c ;
- extern char *mktemp() ;
- static char *tmp_name ;
- static FILE *tmp_file = NULL ;
-
- if( !tmp_file )
- {
- tmp_name = mktemp("yyXXXXXX");
-
- if( !(tmp_file = fopen(tmp_name , "w+")) )
- {
- fprintf(stderr,"Can't open temporary file %s\n",
- tmp_name );
- exit( 1 );
- }
- }
-
- _doprnt( fmt, argp, tmp_file );
-
- putc ( 0, tmp_file );
- rewind ( tmp_file );
-
- while( (c = getc(tmp_file)) != EOF && c )
- (*ofunct)( c, funct_arg );
-
- rewind( tmp_file ); /* Get ready for next call */
- }
-
-
- Example 2: A doprnt() for Unix
-
-