printf() with vector arguments.

Vick Khera khera at juliet.cs.duke.edu
Sat Oct 14 02:50:19 AEST 1989


In article <23078 at sequent.UUCP> paulr at crg3.UUCP (Paul Reger) writes:
>I was wondering if there exists such a beast as:
>void vec_printf(char *fmt,void *args[]);
> ...
>Such a thing would be useful for a tool that can be used with any
>shell - call it shell_printf.  This would have the synopsis:
> ...
>Without the vec_printf() routine, such a tool would be hard to do.
>
>			paulr    (Paul Reger)
>	     {uunet,ucbvax!rutgers!ogccse}!sequent!paulr

I picked up a utility called printf (written by Chris Torek) which does
just what you describe, and does it quite well. It even does roman numeral
conversions. I believe it came across one of the comp.sources groups. Here
is an excerpt from the man page:

NAME
     printf - formatted output at shell command level

SYNOPSIS
     printf format-string [ arg1 ] [ arg2 ] ...

DESCRIPTION
     Printf duplicates  (as  far  as  possible)  the  standard  C
     library  routine  of  the  same  name,  at the shell command
     level.  It is similar to echo, except that  it  formats  its
     arguments  according  to  conversion specifications given in
     the format-string before writing them to the  standard  out-
     put.   For  a thorough explanation of format specifications,
     see printf(3s).

     For the sake of perversity,  printf  implements  one  format
     conversion  not supported by the standard printf subroutine:
     the %r and %R conversions, which  print  integers  as  Roman
     numerals.   The  first  format  produces  lowercase, and the
     second uppercase.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
ARPA:	khera at cs.duke.edu		Department of Computer Science
CSNET:	khera at duke			Duke University
UUCP:	{mcnc,decvax}!duke!khera	Durham, NC 27706



More information about the Comp.unix.questions mailing list