Difference between cfile and cstdiofile and '/R/N' in cstring'

Source: Internet
Author: User

Msdn:

Difference between text mode file and binary mode file
File I/O operations take place in one of two translation modes, text or binary, depending on the mode in which the file is opened. data files are usually processed in text mode. to control the file translation mode, you can:
A. retain the current default setting and specify the alternative mode only when you open selected files.
B. Change the default translation mode directly by setting the global variable _ fmode in your program. The initial default setting of _ fmode is _ o_text, for text mode.

Text mode provides special processing for carriage return-linefeed pairs. when you write a newline character (0x0a) to a text-mode cstdiofile object, the byte pair (0x0d, 0x0a) is sent to the file. when you read, the byte pair (0x0a, 0x0d) is translated to a single 0x0a byte.

Note:

Cstdiofile: readstring
The cstring version of this function removes the '/N' if present; the lptstr version does not.

Note:

The text in the msdn sections (from the topic: cstdiofile: readstring) describes the following issues:
The default cfile file mode is binary, and the default cstdiofile mode is text.
In binary mode, we must enter '/R/N' to start line breaks.'/R' is just a carriage return (return to the first column of the current row ), '/N' is just a line break (to the current column of the next row ).
In text mode, '/R' is automatically completed. When we write a'/N, the system will automatically add a '/R' to the front of the file and save it to the file.

In addition, cfile: typetext can only be used in the cfile subclass. cfile's own read functions cannot use cfile: typetext and cfile: typebinary.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.