- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the text files and binary files in C language?
45 Lectures 4.5 hours
66 Lectures 5.5 hours
Files is collection of records (or) it is a place on hard disk, where data is stored permanently.
Types of Files
There are two types of files in C language which are as follows −
- Text file
- Binary File
It contains alphabets and numbers which are easily understood by human beings.
An error in a text file can be eliminated when seen.
In text file, the text and characters will store one char per byte.
For example, the integer value 4567 will occupy 2 bytes in memory, but, it will occupy 5 bytes in text file.
The data format is usually line-oriented. Here, each line is a separate command.
It contains 1’s and 0’s, which are easily understood by computers.
The error in a binary file corrupts the file and is not easy to detect.
In binary file, the integer value 1245 will occupy 2 bytes in memory and in file.
A binary file always needs a matching software to read or write it.
For example, an MP3 file can be produced by a sound recorder or audio editor, and it can be played in a music player.
MP3 file will not play in an image viewer or a database software.
Files are classified into following
- Sequential files − Here, data is stored and retained in a sequential manner.
- Random access Files − Here, data is stored and retrieved in a random way.
- What are the different operations on files in C language?
- Difference between files written in binary and text mode in C++
- Why files are needed in C programming language?
- Endian order and binary files in C++
- Explain the Random accessing files in C language
- Explain the custom header files in C language
- Reading and Writing to text files in C#
- Explain putc() and getc() functions of files in C language
- What are .pyc files in Python?
- Why does C++ have header files and .cpp files?
- Reading and Writing to text files in Python
- Explain write mode operation of files in C language
- Explain read mode operation of files in C language
- Explain append mode operation of files in C language
- How to print the content into the files using C language?