I need to write a plain PPM file to the standard output. I have it creating the PPM file and everything, I just cannot f开发者_StackOverflowigure out how to get it to send it to the standard output.
Any help you can provide is greatly appreciated,
you should look up these functions: open, read, write, close.
then your code will look something like:
#include <unistd.h>
int fd = open("/path/to/file", O_RDONLY);
char buf[1024];
int buflen;
while((buflen = read(fd, buf, 1024)) > 0)
{
write(1, buf, buflen);
}
close(fd);
please keep in mind this is untested.
fwrite(blah,size_blah,1,stdout);
精彩评论