printf() with vector arguments.
Randal Schwartz
merlyn at iwarp.intel.com
Tue Oct 17 08:24:45 AEST 1989
In article <23078 at sequent.UUCP>, paulr at sequent (Paul Reger) writes:
|
| I was wondering if there exists such a beast as:
|
| void vec_printf(char *fmt,void *args[]);
|
| (as opposed to what we're all familiar with: void printf(char *fmt, ...);)
|
| 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:
|
| shell_printf fmt [arg1 [arg2 [arg3 ... [argn]]]]
|
| and its purpose would be to format and print out its arguments to
| stdout in the exact same manner as printf() does. Such a tool would
| be useful for output in shell scripts. For example:
|
| shell_printf "There are %9d dogs, weighing %9g pounds, and my son's name is '%s'.\n\n\n" 100 12.23 Eric
|
| which would print out to stdout:
|
| ``
| There are 100 dogs, weighing 12.23 punds, and my son's name is 'Eric'.
|
|
| ''
|
| Without the vec_printf() routine, such a tool would be hard to do.
In Perl:
perl -e 'printf "There are %9d dogs, weighing %9g pounds, and my son'\''s name is '\''%s'\''.\n\n\n", at ARGV; exit 0;' 100 12.23 Eric
generates:
There are 100 dogs, weighing 12.23 pounds, and my son's name is 'Eric'.
Close enough?
Just another Perl hacker,
--
/== Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ====\
| on contract to Intel's iWarp project, Hillsboro, Oregon, USA, Sol III |
| merlyn at iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn |
\== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/
More information about the Comp.unix.questions
mailing list