64,636
社区成员
发帖
与我相关
我的任务
分享
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
//#include <sys/types.h>
using namespace std;
//定义文件路径
#define F_Path1 "F:\\2.dat"
#define F_Path2 "F:\\dat+.dat"
#define N1 7062
int main()
{
int i;
//定义文件指针
FILE * fp1;
FILE * fp2;
int *feature1;
feature1=(int*)calloc(N1*130,sizeof(int));
int *feature2;
feature2=(int*)calloc(70000*130,sizeof(int));
//如果文件open失败
if((fp1=fopen(F_Path1,"rb"))==NULL)
{ printf("\nCan't open file");
exit(0);
}
if ((fp2=fopen(F_Path2,"ab+"))==NULL)
{
printf("\nCan't open file");
exit(0);
}
//文件打开成功
for(i=0;i<N1;i++)
{
fread(feature1,sizeof(int),130*N1,fp1);
fseek(fp2,0,2);//把fp2指针移动到离文件结尾0字节处
fwrite(&feature1[128*i+2],4,128,fp2);
}
//操作完成,关闭文件
free(feature1);
free(feature2);
return 0;
}