1. cfile: Read () function:
Virtual uint read (void * Lpbuf, Uint
Ncount );
Throw (cfileexception );
Lpbuf |
Point to the user-provided buffer to receive data read from the file. |
Ncount |
Maximum number of bytes that can be read from a file. For text files, press enter to wrap the line as a line feed character (0x0a), that is, when reading into the memory, 0x0d0a is changed to 0x0a. |
2. cfile: Write () function:
virtual void Write( const void* lpBuf, UINT nCount );
Parameters
-
Lpbuf
-
A pointer to the user-supplied buffer that contains the data to be written to the file.
-
Ncount
-
The number of bytes to be transferred from the buffer. For text-mode files, carriage return-linefeed pairs are counted as single characters.
Self-Summary: When this function writes a string to a file, it also converts the line break (0x0a) to the carriage return line break (0x0d0a). This applies to the text file format.
3. cstdiofile: readstring () function:
virtual LPTSTR ReadString( LPTSTR lpsz, UINT nMax ); virtual BOOL ReadString( CString& rString );
Parameters
-
Lpsz
-
Specifies a pointer to a user-supplied buffer that will receive a null-terminated text string.
-
Nmax
-
Specifies the maximum number of characters to read, not counting the terminating null character.
-
Rstring
-
A reference toCstringObject that will contain in the string when the function returns.
Return Value
-
A pointer to the buffer containing the text data.
NullIf end-of-file was reached without reading any data; or If Boolean,
FalseIf end-of-file was reached without reading any data.
Summary: When this function reads a string from a file, it stops reading the string with the carriage return line break, and the carriage return line break is not read into the memory (for a function that uses the cstring object as the real parameter ), for the first function prototype, the carriage return line break 0x0d0a is converted to 0x0a. If you encounter a carriage return (0x0d), do not stop reading, and change the carriage return (0x0d) to a line break (0x0a) until you encounter a carriage return or a file Terminator.
4. cstdiofile: writestring () function:
Virtual void writestring (
Lpctstr lpsz
);
Parameters
-
Lpsz
-
Specifies a pointer to a buffer containing a null-terminated text string.
Self-Summary: When this function writes characters to a text file, the line break (0x0a) will write 0x0d 0a to the file, that is, the carriage return will wrap two characters. Instead of adding a line break at the end of the string to which lpsz points. When 0x0d is encountered, only 0x0d is written to the file. It does not write the string pointed to by lpsz as a row.
When reading data from a file, if the real parameter is a cstring object, the system will automatically add one character Terminator '\ 0' at the end of the Character Buffer of this object ', when you assign a value to this object using a String constant, the end character '\ 0' is automatically added at the end. However, you must obtain the internal buffer pointer of the string to access this ending character, if you use the member function Str. getat (Str. an asserted error occurs when getlength () is accessed.