Saturday 17 June 2023

Files in C language

What is files in C language?

The input and output operations or running that we have performed or execute so far were done through screen and keyboard only. After closing or termination of program, all the entered or undertake data is lost because main or primary memory is unstable or volatile. If the data has to be used later, then it becomes necessary or required to keep it is eternal or permanent storage device. C supports the theory or concept of files through which data can be stored on the secondary storage device or disk. The stored or keep data can be read whenever required or need. A file is a assembly or collection of related data placed on the disk.

C language, streams, binary logic, files
Files in C language image-1

1.1   Files versus streams

The C language provides or gives a set of rich library functions or task to perform input and output (I/O) operation. Those functions or task can read or write any type of information or data to files. Before we go any far or further in talk over or discussing the C I/O functions, let’s first understand the definitions of files and streams in C.

 

1.1.1          File

In C, a file can refer or mention to a disk file, a final or terminal, a tape drive, or a printer. In other words, a file represents or acts for a concrete or real device with which you want to exchange or interchange information. Before you perform or carry out any communication or links to a file, you have to open the file. Then you need to close the unfold or opened file after you finish exchanging information with it.

 

1.1.2          Stream

The data flow you shift or transfer from your program to a file, or vice versa, is called a stream, which is a sequence or series of bytes. Not like a file, a stream is self-dependent or device-independent. All streams have the same efforts or behavior. To perform or execute I/O operations, you can read from or write to any type of files by simply link or associating a stream to the file.

There are two formats or setup of streams. The first one is called the text stream, which contain or consists of a sequence or series of characters (that is, ASCII data). Depending or turn on the compilers, each character line in a text stream may be finished or terminated by a new line character. Text streams are used for written or textual data, which has a compatible or consistent aspect or appearance from one conditions or environment to another or from one machine or instrument to another.

The second format of streams is calling the binary stream, which is a sequence or series of bytes. The content of an .exe/.obj /a.out file would be one example. Binary streams are first or primarily used for non-textual data, which is need or required to keep the exact contents of the file.


Computer stuff kit tricks of Topics 60.

What are control statement in C language?

What are arrays and pointer in C language?

What is C language basics?