다음을 통해 공유


CArchive::WriteString

이 멤버 함수를 사용 하 여 데이터 버퍼에서 연관 된 파일에 쓸 수 있는 CArchive 개체입니다.

void WriteString( 
   LPCTSTR lpsz  
);

매개 변수

  • lpsz
    Null로 끝나는 문자열을 포함 하는 버퍼에 대 한 포인터를 지정 합니다.

설명

종료 null 문자 ('\ 0')를 파일에 기록 되지 않습니다. 나는 새 줄이 자동으로 작성 됩니다.

WriteString디스크 전체 조건을 포함 하 여 여러 조건에 예외를 throw 합니다.

쓰기 도 사용할 수 있지만 null 문자를 종료 하는 대신이 요청 된 바이트 수를 파일에 씁니다.

예제

CFile myFile(_T("My__test__file.dat"), 
   CFile::modeCreate | CFile::modeReadWrite);
CString str1("String1"), str2("String2"), str;

// Create a storing archive.
CArchive arStore(&myFile, CArchive::store);

// Write str1 and str2 to the archive
arStore.WriteString(str1);
arStore.WriteString(_T("\n"));
arStore.WriteString(str2);
arStore.WriteString(_T("\n"));

// Close the storing archive
arStore.Close();

// Create a loading archive.
myFile.SeekToBegin();
CArchive arLoad(&myFile, CArchive::load);

// Verify the two strings are in the archive.
arLoad.ReadString(str);
ASSERT(str == str1);
arLoad.ReadString(str);
ASSERT(str == str2);

요구 사항

헤더: afx.h

참고 항목

참조

CArchive 클래스

계층 구조 차트