#include <stdio.h>
#include <stdlib.h>
#include<string.h>
int main(void) {
FILE *file;
char msg[3]="12";
file=fopen("/tmp/test/test","a+");
if(file==NULL)
printf("get file eroor\n");
fseek(file,0,SEEK_SET);
printf("offset=%ld\n",ftell(file));
fwrite(msg,sizeof(char),strlen(msg),file);
fclose(file);
return EXIT_SUCCESS;
}
linux下用c写的一个文件操作函数,目的是追加方式打开文件,在文件头写入部分数据,而原来的数据继续保留。但是测试发现数据还是写入了文件末尾?