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
Release: 2023-09-08 16:37:07
forward
1157 people have browsed it

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!

    source:tutorialspoint.com
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template