Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!apple!oliveb!mipos3!omepd!merlyn From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.unix.questions Subject: Re: printf() with vector arguments. Keywords: printf() Message-ID: <5066@omepd.UUCP> Date: 16 Oct 89 22:24:45 GMT References: <23078@sequent.UUCP> Sender: news@omepd.UUCP Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Distribution: comp Organization: Stonehenge; netaccess via Intel, Hillsboro, Oregon, USA Lines: 45 In-reply-to: paulr@sequent.UUCP (Paul Reger) In article <23078@sequent.UUCP>, paulr@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",@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@iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn | \== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/