作为一名编程新手,我写这篇文章的目的只是想为自己创建一个知识库,积累一些自己写编程的心得,激励自己在编程路上越走越远,同时也希望能帮到遇到问题的同胞们。不忘初心,方得始终。
这是刚开始我自己摸索写出的程序,但是结果却不是很理想
.因为写入的内容是覆盖以前文件的内容,这并不是我想要的
。
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4
5
6 int main(void){
7 FILE * pFile=fopen(“1.docx”,”r”);
8 FILE * Buffer=fwrite(“11.docx”,”w”);
9 fseek(pFile,0,SEEK_END);
10 int size=ftell(pFile);
11 if(pFile!=NULL) {
12
//seek zhizhen locate//
13 rewind(pFile);
14 fseek(pFile,size/2,SEEK_SET);
15 fwrite(“abcd”,strlen(“abcd”),1,Buffer);
16 fseek(pFile,0,SEEK_SET);
17 fwrite(“1234”,strlen(“1234”),1,Buffer);
18 fseek(pFile,0,SEEK_END);
19 fwrite(“####”,strlen(“####”),1,Buffer);
20 }
21 else
22 {
23 printf(“can’t open file\n”);
24