c question: *printf'ing arrays

Alexander Best alexbestms at math.uni-muenster.de
Tue Jun 30 18:21:06 UTC 2009


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.

Rick C. Petty schrieb am 2009-06-30:
> On Tue, Jun 30, 2009 at 08:03:21PM +0200, Alexander Best wrote:
> > should be stdout.


> > struct Header *hdr = rom;

> > int new_fd = open("/dev/stdout", O_RDWR);
> > printf("SIZE: %d\n",sizeof(*hdr));
> > write(new_fd, hdr, sizeof(*hdr));
> > close(new_fd);

> Why are you reopening stdout?  It should already be open, so use
> "fileno(stdout)" or just plain "STDOUT_FILENO" instead of "new_fd".

> -- Rick C. Petty


More information about the freebsd-hackers mailing list