Date: Tue, 30 Jun 2009 19:19:24 +0100 From: Igor Mozolevsky <igor@hybrid-lab.co.uk> To: Alexander Best <alexbestms@math.uni-muenster.de> Cc: freebsd-hackers@freebsd.org Subject: Re: c question: *printf'ing arrays Message-ID: <a2b6592c0906301119t4e4fe891ha07895c27b6efec0@mail.gmail.com> In-Reply-To: <permail-20090630180321f7e55a9d00002466-a_best01@message-id.uni-muenster.de> References: <a2b6592c0906301100g55827437o66e09d6ca1269cdd@mail.gmail.com> <permail-20090630180321f7e55a9d00002466-a_best01@message-id.uni-muenster.de>
next in thread | previous in thread | raw e-mail | index | archive | help
2009/6/30 Alexander Best <alexbestms@math.uni-muenster.de>: > 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); You should really be checking what open returns, opening /dev/stdout for reading is a bit weird not sure if that would work, and most likely it's already open... Just use fileno(...):- #include <unistd.h> #include <stdio.h> int main(void) { write(fileno(stdout), "Hello world!\n", 13); return 0; } Cheers, -- Igor
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?a2b6592c0906301119t4e4fe891ha07895c27b6efec0>