Menu
Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
how to write binary data to stdout?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Rouben Rostamian, post: 1682910"] Consider the following demo program: #include <stdio.h> int main(void) { unsigned char c; for (c=0; c<15; c++) putchar(c); return 0; } As is, the output of the program is platform-dependent. For instance, in the UNIX environment, it puts 15 characters to stdout. Under windows it puts out at least 16, because c=10 gets translated to newline+carriage return. This brings me to: Question: Is it possible to close stdout then reopen it in binary mode in a platform-independent way? If that were possible, then the binary-mode output of the program would be the same on all platforms. The purpose of my real program (not this demo,) is to act as a filter from stdin to stdout, therefore fopen(filename, "wb") is of not much help. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
how to write binary data to stdout?
Top