Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Im writing a “filter\ for binary files, but stdin and stdout are preopened as text streams. How can I change their mode to binary?

0
Posted

Im writing a “filter\ for binary files, but stdin and stdout are preopened as text streams. How can I change their mode to binary?

0

There is no standard way to do this. On Unix-like systems, there is no text/binary distinction, so there is no need to change the mode. Some MS-DOS compilers supply a setmode call. Otherwise, you’re on your own. comp.lang.c FAQ list ยท Question 12.40 Q: What’s the difference between text and binary I/O? A: In text mode, a file is assumed to consist of lines of printable characters (perhaps including tabs). The routines in the stdio library (getc, putc, and all the rest) translate between the underlying system’s end-of-line representation and the single \n used in C programs. C programs which simply read and write text therefore don’t have to worry about the underlying system’s newline conventions: when a C program writes a ‘\n’, the stdio library writes the appropriate end-of-line indication, and when the stdio library detects an end-of-line while reading, it returns a single ‘\n’ to the calling program. [footnote] In binary mode, on the other hand, bytes are read and written between th

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123