就是英文版的哈利波特的一部分 Harry Potter and the Deathly HallowsC0="Chapter One: The Dark Lord Ascending" Chapter One The Dark Lord Ascending The two men appeared out of nowhere, a few yards apart in the narrow, moonlit lane. For a second they stood quite still, wands directed at each other's chests; then, recognizing each other, they stowed their wands beneath their cloaks and started walking briskly in the same direction. "News?" asked the taller of the two. "The best," replied Severus Snape. The lane was bordered on the left by wild, low-growing brambles, on the right by a high, neatly manicured hedge. The men's long cloaks flapped around their ankles as they marched. "Thought I might be late," said Yaxley, his blunt features sliding in and out of sight as the branches of overhanging trees broke the moonlight. "It was a little trickier than I expected. But I hope he will be satisfied. You sound confident that your reception will be good?" Snape nodded, but did not elaborate. They turned right, into a wide driveway that led off the lane. The high hedge curved into them, running off into the distance beyond the pair of imposing wrought-iron gates barring the men's way. Neither of them broke step: In silence both raised their left arms in a kind of salute and passed straight through, as though the dark metal was smoke. The yew hedges muffled the sound of the men's footsteps. There was a rustle somewhere to their right: Yaxley drew his wand again pointing it over his companion's head, but the source of the noise proved to be nothing more than a pure-white peacock, strutting majestically along the top of the hedge. "He always did himself well, Lucius. Peacocks " Yaxley thrust his wand back under his cloak with a snort. A handsome manor house grew out of the darkness at the end of the straight drive, lights glinting in the diamond paned downstairs windows. Somewhere in the dark garden beyond the hedge a fountain was playing. Gravel crackled beneath their feet as Snape and Yaxley sped toward the front door, which swung inward at their approach, though nobody had visibly opened it. The hallway was large, dimly lit, and sumptuously decorated, with a magnificent
// msdn上的 virtual void WriteString( LPCTSTR lpsz ); The terminating null character ('\0') is not written to the file. Any newline character in lpsz is written to the file as a carriage return–linefeed pair.// 以前没注意过。
猜测而已,
各个系统的换行符是不同的
Windows是'\r\n'
Unix是'\n'
苹果是'\r'
下面是我写的源码
void OperFile::Oper(LPCTSTR InFileName,LPCTSTR OutFileName)
{
CStdioFile InFile,OutFile;
CString InText="",OutText="";
InFile.Open(InFileName,CFile::modeRead|CFile::typeText);
OutFile.Open(OutFileName,CFile::modeCreate|CFile::modeWrite|CFile::typeText);
while(InFile.ReadString(InText))
{
OutText=InText;
OutText+="\r\n";
OutFile.WriteString(OutText);
}
InFile.Close();
OutFile.Close();
}
OutText+="\r\n";
OutFile.WriteString(OutText);// 每次写入,每行都多了"\r\n";
// WriteString会自动在行尾加上"\r\n"
Harry Potter and the Deathly HallowsC0="Chapter One: The Dark Lord Ascending"
Chapter One
The Dark Lord Ascending
The two men appeared out of nowhere, a few yards apart in the narrow, moonlit lane. For a second they stood quite still, wands directed at each other's chests; then, recognizing each other, they stowed their wands beneath their cloaks and started walking briskly in the same direction. "News?" asked the taller of the two. "The best," replied Severus Snape. The lane was bordered on the left by wild, low-growing brambles, on the right by a high, neatly manicured hedge. The men's long cloaks flapped around their ankles as they marched. "Thought I might be late," said Yaxley, his blunt features sliding in and out of sight as the branches of overhanging trees broke the moonlight. "It was a little trickier than I expected. But I hope he will be satisfied. You sound confident that your reception will be good?" Snape nodded, but did not elaborate. They turned right, into a wide driveway that led off the lane. The high hedge curved into them, running off into the distance beyond the pair of imposing wrought-iron gates barring the men's way. Neither of them broke step: In silence both raised their left arms in a kind of salute and passed straight through, as though the dark metal was smoke.
The yew hedges muffled the sound of the men's footsteps. There was a rustle somewhere to their right: Yaxley drew his wand again pointing it over his companion's head, but the source of the noise proved to be nothing more than a pure-white peacock, strutting majestically along the top of the hedge.
"He always did himself well, Lucius. Peacocks " Yaxley thrust his wand back under his cloak with a snort.
A handsome manor house grew out of the darkness at the end of the straight drive, lights glinting in the diamond paned downstairs windows. Somewhere in the dark garden beyond the hedge a fountain was playing. Gravel crackled beneath their feet as Snape and Yaxley sped toward the front door, which swung inward at their approach, though nobody had visibly opened it.
The hallway was large, dimly lit, and sumptuously decorated, with a magnificent
如果你的代码是sf.WriteString("ab\n");
那么得到的结果数据是ab\r\n
OutText+="\r\n";
OutFile.WriteString(OutText);
OutText+="\r\n";
OutFile.WriteString(OutText);// 改为
OutText=InText;
OutText+="\n"; // 如果加了"\r\n",输出就成了"\r\n\r\n"
OutFile.WriteString(OutText);
virtual void WriteString(
LPCTSTR lpsz
);
The terminating null character ('\0') is not written to the file. Any newline character in lpsz is written to the file as a carriage return–linefeed pair.// 以前没注意过。