Answer: There are two types of streams in C: Text streams and Binary streams. Text streams may have certain characteristics that may vary from system to system. One of these is maximum length of text line. Though standard defines it to be at least 254 characters other implementations might define this differently. Another characteristic is the manner in which a line is terminated. Notice that a text line on MS-DOS system is terminated with a carriage return/newline character pair. On UNIX and LINUX system, line terminates with a newline character.
Notice that standard defines a text line to be zero or more characters followed by terminating newline character. On implementations, for ex. MS-DOS, where external representation of text line differs from this definition, library functions take care of translating between external and internal forms. A text line on MS-DOS system is terminated with carriage return/newline character pair. Carriage return character is discarded while reading from a file on MS-DOS and carriage return is added with newline when data is being written to MS-DOS. The ability to manipulate the text without regard to external appearance simplifies creation of portable programs.
Bytes in binary stream are written to the file or device exactly as program wrote them and are delivered to the program exactly as they were read form file or device. Nothing is changed in any manner. This type of stream is useful for non-textual data. Yet, this stream can be used for textual data as well when we don’t want library functions to modify end-of-line characters.
Sanfoundry Global Education & Learning Series – 1000 C Tutorials.
- Check Computer Science Books
- Practice BCA MCQs
- Apply for Computer Science Internship
- Check C Books
- Watch Advanced C Programming Videos