Home >Backend Development >C++ >In C language, what are text files and binary files?

In C language, what are text files and binary files?

WBOY
WBOYforward
2023-09-08 16:37:071159browse

In C language, what are text files and binary files?

A file is a collection of records (or) a place on a hard disk where data is permanently stored.

File types

There are two types of file languages ​​in C as follows-

  • Text files
  • Binary files

Text file

  • # It contains letters and numbers that are easily understandable by humans.

  • Errors in text files can be eliminated in the following situations:

  • In text files, text and characters are stored one character per byte .

  • For example the integer value 4567 will occupy 2 bytes in memory, but will occupy 5 bytes in the text file.

  • Data formats are usually row-oriented. Here, each line is a separate command.

  • Binary file

    • It contains 1s and 0s and is easily understood by computers.

    • Errors in binary files can corrupt the file and are difficult to detect.

    • In a binary file, the integer value 1245 will occupy 2 bytes in memory and file.

    • Binary files always require supporting software to read or write it.

    • For example, MP3 files can be generated by a recorder or audio editor and can be played in a music player.

    • MP3 files cannot be played in image viewers or database software.

    Files are classified into the following categories

    • Sequential Files - Here, the data is stored and retained in a sequential manner.
    • Random Access File - Here, the data is stored in a sequential manner and retrieved in a random manner.

    The above is the detailed content of In C language, what are text files and binary files?. For more information, please follow other related articles on the PHP Chinese website!

    Statement:
    This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete