Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Surrpressing arguements in printf

62 views
Skip to first unread message

Jason Balser

unread,
Feb 7, 1995, 5:23:39 PM2/7/95
to
Does anyone know if there is a way to have printf "ignore" an argument in its
argument list? As an example, is there a way to get printf to skip over the
argument A in the following and print B:

printf("Print some stuff here %d.",A,B)

I want the value of B printed but not A. Due to the nature of what I am
doing,I cannot reverse the order of A and B.

Any help would be appreciated.

Please respond to oba...@clemson.edu

Thanks,
Jason

--

****************************************************************************
* Jason Balser * "When you have eliminated the impossible, *
* oba...@clemson.edu * whatever remains, however improbable, *

Peter Holzer

unread,
Feb 10, 1995, 6:49:33 PM2/10/95
to
oba...@hubcap.clemson.edu (Jason Balser) writes:

>Does anyone know if there is a way to have printf "ignore" an argument in its
>argument list? As an example, is there a way to get printf to skip over the
>argument A in the following and print B:

> printf("Print some stuff here %d.",A,B)

>I want the value of B printed but not A. Due to the nature of what I am
>doing,I cannot reverse the order of A and B.

Not in C as described in the ANSI and ISO standards. The X/Open standard
(to justify the `std' in the newsgroup name :-) specifies a mechanism
for reordering the arguments of printf. It looks something like this
printf ("B=%2$d, A=%1$d.", A, B);
I think I remember that you had to use all of the arguments, though
(sorry, I don't have X/Open at hand and the HP-UX manual pages aren't a
good indication of standards conformance).

hp

>Any help would be appreciated.

>Please respond to oba...@clemson.edu

>Thanks,
>Jason

>--

> ****************************************************************************
> * Jason Balser * "When you have eliminated the impossible, *
> * oba...@clemson.edu * whatever remains, however improbable, *

--
_ | Peter Holzer | h...@vmars.tuwien.ac.at | h...@wsr.ac.at
|_|_) |------------------------------------------------------
| | | ...and it's finished! It only has to be written.
__/ | -- Karl Lehenbauer

0 new messages