我有一个奇怪的问题:
我将一个文件读入缓存,然后尝试在ssh(Linux)中运行它。
我的文件包含:
We
I
a
这是我的缓冲区:
现在我创建了一个新文件,并将缓冲区粘贴到这个新文件中:
FILE*nem_file_name;
nem_file_name= fopen("email1.clear","wb"); //create the file if not exist.
fwrite (buf, sizeof(char), strlen(buf),nem_file_name); //write the new sensored mail to the file.
在这种情况下,文件email1.clear已创建,但它包含以下内容:
We Ia
当我将其复制到剪贴板并粘贴到此主题时,它被粘贴为:We
I
a
为什么我的文件中没有“结束行”?我希望它能像我的剪贴板一样。
更新 我试图手动创建缓冲区:
char buf[10];
buf[0] = 'W';
buf[1] = 'e';
buf[2] = 32;
buf[3] = 13;
buf[4] = 10;
buf[5] = 'I';
buf[6] = 13;
buf[7] = 10;
buf[8] = 'a';
buf[9] = 0;
(请注意,我没有将文件读入缓冲区,而是手动执行此操作)
然后:
FILE*nem_file_name;
nem_file_name= fopen("email1.clear","wb"); //create the file if not exist.
fwrite (buf, sizeof(char), strlen(buf),nem_file_name);
文件email1.clear
已按照我的要求创建:
We
I
a
我无法理解它!