Another printf-type question

gwyn at brl-smoke.UUCP gwyn at brl-smoke.UUCP
Sat Jul 12 23:40:40 AEST 1986


In article <2138 at brl-smoke.ARPA> LINNDR%VUENGVAX.BITNET at WISCVM.ARPA writes:
>invprintf(fmt,args)
>{
>        printf(<string to go into inverse video mode>);
>        printf(fmt,args);
>        printf(<string to leave inverse mode>);
>}
>
>This simple solution didn't work. Oh great gurus of such things, what
>should I have done?

Assuming you're using UNIX System V Release 2.0 for sake of concreteness,

#include	<stdio.h>
#include	<varargs.h>

void
invprintf( va_alist )
	va_dcl
	{
	char	*fmt;			/* printf control string */
	va_list	args;			/* argument pointer */

	(void)fputs( "string to enter inverse video mode", stdout );

	va_start( args );

	fmt = va_arg( args, char * );

	(void)vprintf( fmt, args );	/* warning! not printf(va_arg etc. */

	va_end( args );

	(void)fputs( "string to leave inverse video mode", stdout );
	}

The final mechanism of ANSI X3J11 will probably be slightly different.

P.S.  You should perhaps also test whether the write to the terminal succeeds.



More information about the Comp.lang.c mailing list