c question: *printf'ing arrays

Stephen Montgomery-Smith stephen at missouri.edu
Tue Jun 30 19:27:50 UTC 2009


Alexander Best wrote:
> thanks. now the output gets redirected using >. i'm quite new to programming
> under unix. sorry for the inconvenience.
> 
> so i guess there is no really easy way to output an inhomogeneous struct to
> stdout without using a loop to output each array contained in the struct.
> 
> cheers.

I think you are asking for a print command, that when given a structure, 
can look at the data type of each element of the structure, and produces 
the appropriate print command for each data type.

I think what you are asking for is antithetical to the philosophy of C - 
for example, the printf command demands that you tell the printf command 
what are the data types of the data you give to it.

So I think that the kind of long winded print command you are advocating 
is the correct way to do it.

Stephen


More information about the freebsd-hackers mailing list