CStdioFile::ReadString

virtual LPTSTR ReadString( LPTSTR lpsz, UINT nMax );
throw( CFileException );

BOOL ReadString(CString& rString);
throw( CFileException );

Return Value

A pointer to the buffer containing the text data. NULL if end-of-file was reached without reading any data; or if boolean, FALSE if end-of-file was reached without reading any data.

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 to a CString object that will contain the string when the function returns.

Remarks

Reads text data into a buffer, up to a limit of nMax–1 characters, from the file associated with the CStdioFile object. Reading is stopped by the first newline character. If, in that case, fewer than nMax–1 characters have been read, a newline character is stored in the buffer. A null character (‘\0’) is appended in either case.

CFile::Read is also available for text-mode input, but it does not terminate on a carriage return–linefeed pair.

Note   The CString version of this function removes the '/n' if present; the LPTSTR version does not.

Example

// example for CStdioFile::ReadString
extern CStdioFile f;
char buf[100];

f.ReadString( buf, 99 );

CStdioFile OverviewClass MembersHierarchy Chart

See Also   CStdioFile::WriteString, CFile::Read