Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of reading and writing binary files and sequential reading and writing in CUniverse +?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the use of binary files and sequential reading and writing in CAccord +. The article is very detailed and has a certain reference value. Interested friends must finish reading it!

Overview

Unlike text files, binary files can be used for any type of file (including text files).

Binary vs ASCII

For numerical data, the ASCII form is different from the binary form. ASCII files are intuitive and easy to read, but they generally take up more storage space and take time to convert. Binary file is the internal form of computer, which saves space and does not need to be converted, but can not be displayed intuitively.

For character information, it is stored in ASCII code in memory, whether output by ASCII file or binary file, the form is the same.

Binary write # include # include using namespace std;int main () {int x = 12345; ofstream outfile ("binary.txt", ios::binary); outfile.write ((char*) & x, 2); / / write outfile.close (); / / release return 0;}

Output result:

ASCII write

Write int x = 12345 to the file.

# include # include using namespace std;int main () {int x = 12345; ofstream outfile ("ASCII.txt"); outfile

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report