As @JonathanLeffler pointed out, whatever your V3ARGS(...)
is, it's probably a #define
macro that resolves to a comma list like x, y, z
. This means you are essentially asking what format string only prints x if you said:
printf("some format string here", x, y, z);
You're in luck, as it so happens that it is legal to pass fewer format specifiers than you pass arguments:
Passing too many arguments to printf
So if you only want the first argument, then only use one specifier:
printf("%g", x, y, z);
It gets trickier if you wanted just the second, or just the third. Because there's no generalized way to skip values; the format specifiers are consumed in order (though there is a POSIX extension to access by number):
Is there a "null" printf code that doesn't print anything, used to skip a parameter?
So if you got into a case like this and wanted to just print z, and couldn't modify the macro, this should work in ANSI C99:
typedef struct {
double x,
double y,
double z
} Coordinate;
Coordinate temp;
temp = (Coordinate){ V3ARGS(ell->a) };
printf("%g", temp.z);
That takes advantage of the fact that structure fields can be initialized by a comma delimited list in that style of assignment.
But you might be better served by looking at the definition of V3ARGS. Because it may well be doing something like:
#define V3ARGS(foo) (foo).x, (foo).y, (foo).z
In which case you could just say something like:
printf("%g", ell->a.z);