472,983 Members | 2,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,983 software developers and data experts.

text and binary streams

In K & R ANSI C book(2nd Edition), in page 241, the following lines
are mentioned.

"The library supports text streams and binary streams, although on
some systems, notably UNIX, these are identical."

Here I am unable to understand what is meant by saying "the streams
are identical" ?

Kindly clarify. If possible give an example so that I can understand.

Thanks
V.Subramanian
Aug 23 '08 #1
2 1588
In article <b4**********************************@j1g2000prb.g ooglegroups.com>,
su**************@yahoo.com, India <su**************@yahoo.comwrote:
>In K & R ANSI C book(2nd Edition), in page 241, the following lines
are mentioned.

"The library supports text streams and binary streams, although on
some systems, notably UNIX, these are identical."

Here I am unable to understand what is meant by saying "the streams
are identical" ?
The best-known example is the difference in how line-endings are
represented in unix and msdos-derived systems. Unix uses a single
linefeed character at the end of each line. Windows uses the
two-character sequence carriage-return-linefeed.

C specifies that when reading text files you get a linefeed at the end
of each line, so on MS Windows the system has to translate cr-lf to lf
in text mode (and the reverse for writing), but not in binary mode.
On unix the file representation is already the same as C's, so no
translation is needed in text mode, and it works just the same way as
binary mode.

-- Richard
--
Please remember to mention me / in tapes you leave behind.
Aug 23 '08 #2
On Sun, 24 Aug 2008 03:36:46 UTC, Jack Klein <ja*******@spamcop.net>
wrote:
>
Which only goes to prove that if there were "\n\r" systems in the
early 80's, they weren't used in the sort of places that bought our
products.
I don't think that ever a system using '\n\r' would exist. Because
based on the very old times before even CP/M was existent there were
existent priters (e.g. on TTY) who used '\r' to move the print head to
begin of line only and '\n' only to move the paper try a line up.
Whereas using '\n' followed by '\r' and then the next letter printing
out that letter on the fly where the carridge was underway to begin of
line, whereas the sequence '\r\n' caused the print unit to wait until
the carridge had reached t
he begin of line position before the '\n' was carried out.

A sample:

You had used
fprintf("----------------------------------------------------\n\r");
fprintf("monkey\r/n");
The printout looked like
-
------------------------------------------------------------
ey k on m
instead of
------------------------------------------------------------
monkey

as it should. So it was essential to print out '\r' before '\n' to
give the print unit time to let the carridge return, and then paper
try was holding the unit until it was finished the paper one line
forward, because it had to reead its punched paper stripe that
signaled the step wide a line and a page was high.

--
Tschau/Bye
Herbert

Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2R Deutsch ist da!
Aug 24 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tron Thomas | last post by:
What does binary mode for an ofstream object do anyway? Despite which mode the stream uses, operator << writes numeric value as their ASCII representation. I read on the Internet that it is...
8
by: Dave Moore | last post by:
I realize this is a somewhat platform specific question, but I think it is still of general enough interest to ask it here ... if I am wrong I guess I will find out 8*). As we all know, DOS uses...
14
by: nic977 | last post by:
I am asked to write a simple program to displays the last n lines from a given text file. But I have no ideas how C defines a "line" in a text file. How does it tell if it is the end of the line,...
8
by: Yeow | last post by:
hello, i was trying to use the fread function on SunOS and ran into some trouble. i made a simple test as follows: i'm trying to read in a binary file (generated from a fortran code) that...
36
by: Wei Su | last post by:
Hi, I have a text file abc.txt and it looks like: 12 34 56 23 45 56 33 56 78 ... .. .. ... .. .. I want to get how many rows totally in the text file, how to do this? Thanks.
26
by: Patient Guy | last post by:
Has anyone written code that successfully manipulates binary file data using Javascript? It might---and in the case of doing I/O, will---make use of browser- specific functions (ActiveX/COM with...
8
by: FUGATO | last post by:
I need to help in my assignment. I need to wrap a text with the following indications: 1.If you have reached the end of the line (number of characters on this line >= 40) AND you have reached the...
7
by: Hallvard B Furuseth | last post by:
I'm trying to clean up a program which does arithmetic on text file positions, and also reads text files in binary mode. I can't easily get rid of it all, so I'm wondering which of the following...
6
by: Alexander Vasilevsky | last post by:
How do I know whether the file is text or binary? http://www.alvas.net - Audio tools for C# and VB.Net developers + Christmas discount
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.