CString temp; while(bug.GetLength()>30) { temp = bug.Left(30); write temp to file and add \r\n buf.delete(30,0); } temp = buf; write temp to file end
void CWriteReturnDlg::OnWrite() { //实现每30个字符一个回车。 CString str ="The production of this book required the efforts of many people, but two in particular deserve to be singled out for their diligent, sustained, and unselfish efforts. Sally Stickney, the book's principal editor, navigated me through that minefield called the English language and contributed greatly to the book's readability. Marc Young, whose talents as a technical editor are nothing short of amazing, was relentless in tracking down bugs, testing sample code, and verifying facts. Sally, Marc: This book is immeasurably better because of you. Thanks."; int iLen = str.GetLength() + 1; char *contents = new char[iLen]; char *contentsReturn = new char[2 * iLen]; strcpy(contents,str);
for (int i = 0, j = 0; contents[i] != '\0'; i++) { if (!(i%30)) { contentsReturn[j++] = '\r'; contentsReturn[j++] = '\n'; } contentsReturn[j++] = contents[i]; } contentsReturn[j] = '\0';
while(bug.GetLength()>30)
{
temp = bug.Left(30);
write temp to file and add \r\n
buf.delete(30,0);
}
temp = buf;
write temp to file
end
{
//实现每30个字符一个回车。
CString str ="The production of this book required the efforts of many people, but two in particular deserve to be singled out for their diligent, sustained, and unselfish efforts. Sally Stickney, the book's principal editor, navigated me through that minefield called the English language and contributed greatly to the book's readability. Marc Young, whose talents as a technical editor are nothing short of amazing, was relentless in tracking down bugs, testing sample code, and verifying facts. Sally, Marc: This book is immeasurably better because of you. Thanks.";
int iLen = str.GetLength() + 1;
char *contents = new char[iLen];
char *contentsReturn = new char[2 * iLen];
strcpy(contents,str);
for (int i = 0, j = 0; contents[i] != '\0'; i++)
{
if (!(i%30))
{
contentsReturn[j++] = '\r';
contentsReturn[j++] = '\n';
}
contentsReturn[j++] = contents[i];
}
contentsReturn[j] = '\0';
MessageBox(contentsReturn); //将这里改为你写文件的操作就可以了
delete []contents;
delete []contentsReturn;
}
保存的TXT文件,在找开时说文件太大不能打开。
其实就几百个字节都会说文件太大,是什么原因?