C + + read and write file operation code
Constant Value DescriptionFmopenread 0 opens with read-only propertyFmopenwrite 1 opens with write-only propertyFmopenreadwrite 2 opens with read/write propertiesFmsharecompat 0 Compatible FCB mode (the
In the programming process, file operations are a common problem. In C ++ builder, you can use multiple methods to operate files, I will introduce this in detail in the following parts:
1. C-based file operations;
2. File Operations Based on C ++;
Detailed usage of C language file read/write operations
C file operations1. Read one file to another, and use "(ch = getc (fp ))! = EOF "to determine whether the file ends. If
The file size is the same as the size of the original file.
Text or
Detailed usage of C language file read/write operationsC file operations1. Read one file to another, and use "(ch = getc (fp ))! = EOF "to determine whether the file ends. IfThe file size is the same as the size of the original file.Text or binary
C # Introduction to common file read/write classes,
First, you must be familiar with file and folder operations in. NET. File and Directory are the two most important classes. Understanding them will greatly facilitate the implementation of
I. file read/write
As mentioned above, stream reads and writes mainly include , get, put, read, write, and other operations. ofstream inherits from ostream, and ifstream inherits from istream, therefore, the operation functions are consistent.
C ++
First, you must be familiar with file and folder operations in. net. File and directory are the two most important classes. Understanding them will greatly facilitate the implementation of subsequent functions.This section briefly introduces two.
For security reasons, it's a good idea to assign a name to an open file object so that you can quickly close the file to prevent unwanted file objects from consuming memory after you complete the operation. For example, read a text file:
C-based file operations
In ANSI C, the operation of the file is divided into two ways, that is, streaming file operations and I/O file operations, respectively, described below.
One, streaming file operation
The file operations in this way have an
Http://blog.sina.com.cn/s/blog_61437b3b0102v0bt.htmlhttp://blog.csdn.net/chenwk891/article/details/8776479 in c\c++, the file operations are implemented by the library function, mainly divided into two types of read and write operations, the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.