开发者

sending a file to stdout in C

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜