#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define Size 500
void main()
{
FILE *file;
if((file = fopen("test.264","rb"))==NULL)
{
printf("Cannot open the file.\n");
exit(0);
}
// FILE*pf;
// pf=file;
int position_last,position_now;
position_last=position_now=0;
int *size=new int[Size];
memset(size,0,Size);
int count=0;
FILE*doc;
if((doc = fopen("size.txt","w"))==NULL)
{
printf("Cannot open the txt.\n");
exit(0);
}
char *flag;
flag=new char[4];
flag[0]=0*0;
flag[1]=0*0;
flag[2]=0*0;
flag[3]=1;
int i=0;
for(int j=0;;j++)
{
char *buf;
buf=new char[4];
fread(buf,sizeof(char),4,file);
// char *buf1;char *buf2;char *buf3;char *buf4;
// if(strcmp(0*00,ch[0])==0&&strcmp(0*00,ch[1])==0&&strcmp(0*00,ch[2])==0&&strcmp(0*01,ch[3])==0))
// if(strcmp(flag,buf)==0)
if(strcmp(buf,flag)==0&&strcmp(buf+1,flag+1)==0&&strcmp(buf+2,flag+2)==0&&strcmp(buf+3,flag+3)==0)
{
i++;
if(i==3)
{
position_now=ftell(file);
}
else if(i>3)
{
position_last=position_now;
position_now=ftell(file);
size[count]=position_now-position_last;
char ch[5];
itoa(size[count],ch,10);
fwrite(ch,1,5,doc);
fwrite(" ",sizeof(" "),1,doc);
if(i%5==0)
fwrite("\r\n",sizeof("\r\n"),1,doc);
count++;
}
}
delete[] buf;
if(feof(file))
{
position_last=position_now;
position_now=ftell(file);
count++;
break;
}
fseek(file,-3,SEEK_CUR);
}
printf("count is:%d\n",count);
delete[] size;
fclose(file);
fclose(doc);
}
评论5
最新资源