Types of files in C language are ,Text Files and Binary Files.

Basic features of text files:

a. Readability:
  File Can be opened and viewed directly using any standard text editor such as Notepad or TextEdit. What you see on the screen is what appears as plain text.
b. Content:
  Most text-based content is stored with source code (.c, .cpp, .h), configuration files, log files, or any information that users want to understand.
c.Structure:
  Text is organized into lines, each ending with a special character (\n) indicating the end of the line. This is different from how the text looks visually, where the line spacing for the text can be adjusted.
d. C Functions:
  C Language provides various functions like fscanf, fopen, fgets, fprintf and fputs to work with text files. These functions allow you to open, write, read and manipulate text information in a file.

Read data from existing files:
The program can access and process information stored in files. Programs can read and access data from existing files using file handling. This involves:
1. Opening the file using fopen().
2. Reading data in chunks using fscanf()or fread() .
3. Processing the data (disp laying, calculations, etc.).
4. Checking for errors if the file cannot be opened.
5. Closing the file using fclose().
These programs allow you to read contents in files from computers, and allow you to perform the operations for various reasons.


2. Binary files:

In the broader context of computers, a binary file is a type of computer file that stores information in a non-human-readable format. Unlike text files, which use characters such as letters and numbers, binary files use a sequence of bytes to represent data.
meaning they use sequences of 0s and 1s to represent various data types like numbers, images, or audio.
Binary files are not directly human-readable, because the file format requires their contents to be interpreted by a specific program or library. They may have different extensions depending on the data they contain (for example,.mp3 for audio, .jpg for images,.exe for executable programs).

Real Use Cases: Storing images, audio, video files
Storing scientific data
Executable program files
Saving program data (e.g., game progress)
Example:
An image file named "c-language.jpg" will contain binary data representing the color information of the image, which cannot be directly understood by humans.


Features of binary files:

Unreadable by humans: They store data using raw bytes instead of characters which cannot be directly understood by humans.
Variable Structure: Unlike the well-defined structure of text files (lines and characters), binary files can have different internal structures depending on the format. Some may have headers with metadata, others may be plain and contain no additional information.
Efficient storage. By using raw data, they provide more compact storage than text files, especially for complex data such as images, audio files, or numeric arrays. Platform independence: Text files can be more platform independent than text files requiring specific encoding, although some formats may require special software to be interpreted on different platforms.

summary: understanding the difference between binary and text files in C Programming Language is important to choosing the right file type for your specific needs and to ensure that your program stores and retrieves data efficiently.


Previous Topic:-->> File Handling in C. || Next topic:-->>File Operaions.