用C程序合成电影中英文字幕的程序,求助!
程序代码:#include <stdio.h>
#include <string.h>
void main()
{
FILE *fa,*fb,*fc;
char ch1,ch2,str1[100],str2[100],str3[100],str4[100];
int i=0,j=0,k=0,l=0;
fa=fopen("eng.txt","r");
fb=fopen("chs.txt","r");
fc=fopen("jg.txt","w");
while(!feof(fa)&&!feof(fb))
{
ch1=fgetc(fa); //读取fa指向的文件英文字幕
ch2=fgetc(fa);
while(ch1!='\n'||ch2!='0') //读取时间信息行的开始
{
ch1=ch2;
ch2=fgetc(fa);
}
while(ch2!='\n') //将时间读到数组str1中
{
str1[i]=ch2;
ch2=fgetc(fa);
i++;
}
str1[i]='\0';
ch2=fgetc(fa);
while(ch2!='\n') //将字幕行读到数组str2中
{
str2[j]=ch2;
ch2=fgetc(fa);
j++;
} //如果字幕有两行
ch2=fgetc(fa);
while(ch2!='\n')
{
str2[j]=ch2;
ch2=fgetc(fa);
j++;
}
str2[j]='\0';
ch1=fgetc(fb); //读取fb指向的文件 中文字幕
ch2=fgetc(fb);
while(ch1!='\n'||ch2!='0') //读取时间信息行的开始
{
ch1=ch2;
ch2=fgetc(fb);
}
while(ch2!='\n') //读取时间到数组str3中
{
str3[k]=ch2;
ch2=fgetc(fb);
k++;
}
str3[k]='\0';
ch2=fgetc(fb); //读取字幕到数组str4中
while(ch2!='\n')
{
str4[l]=ch2;
ch2=fgetc(fb);
l++;
}
ch2=fgetc(fb);
while(ch2!='\n')
{
str4[l]=ch2;
ch2=fgetc(fb);
l++;
}
str4[l]='\0';
if(strcmp(str1,str3)==0) //时间相等的话
{
strcat(str2,str4); //复制连接字幕
fputs(str1,fc); //时间写到文件里去
fputs(str2,fc); //字幕写到str2里面去
}
}
}我想做一个电影中英文字幕合成的程序,做到这里有点问题,还请各位看下,这样写不知道成不成,对文件的操作不是很懂,还望大侠指点一二!可以加QQ讨论:1004869498.我先上课去了,上完课再和大家讨论了!









