read and change time in .srt file

can anyone help me to change the time in .srt file
wat i support to is increase subtitle time in 3 seconds(i.e the subtitle will after actors speaks 3 seconds)
wat i have so far:

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "Subtitle.h"
typedef char string[16];
struct subStruct{
int order;
long statHour;
long statMin;
long statSec;
long endHour;
long endMin;
long endSec;
string sub;
};

/*
* Check all values in the array
* intput : array of characters
* output : No Change
* return :
* TRUE if array contains only [a..z A..Z 0..9]
FALSE if vise versa
*/
int check_value(char * value){
int i;
int len = strlen(value);//lenght of the string
for(i = 0; i<len;i++){
if(isalnum(*(value + i))==FALSE)
return FALSE;
}

}
int check_param(char *i_option,char *i_value,char *d_option,char *d_value,char *t_option,char *t_value,char *o_option, char *o_value){
int param_num;
if(param_num >= 7){
//check option
if(strcmp(i_option,"-f") != 0) return FALSE;
if(strcmp(d_option,"-d") != 0) return FALSE;
if((strcmp(d_value,"-u") && strcmp(d_value,"-d")) != 0) return FALSE;
if(strcmp(t_option,"-t") != 0) return FALSE;
if(strcmp(o_option,"-o") != 0) return FALSE;

if(check_value(i_value)==FALSE);
if(check_value(d_value)==FALSE);
if(check_value(t_value)==FALSE);
if(check_value(o_value)==FALSE);
} else {
return FALSE;
}
return TRUE;
}
long HourconvertMil( long hour){
return (hour * 3600000);
}
long MinconvertMil( long min){
return (min * 60000);
}

long SecconvertMil( long sec){
return (sec * 1000);
}
void convertStruct(char *fileName,struct subStruct * sub){
FILE *textFile;

int count = 0;
char buff[500];
char *ptr;
textFile = fopen(fileName,"r"); /* open text file for reading */

if (textFile == NULL){
perror("File can't be found");
return;
}
sub = (struct subStruct*) malloc(sizeof(struct subStruct));
while(!feof(textFile)){
fgets(buff, 255, textFile);
(*sub).order = ptr[0]; /*subttile order */
printf("\n");
if(ptr ==':'){
ptr = strtok(0, ":");
(*sub).statHour = ptr[0];
ptr = strtok(0, ":");
(*sub).statMin = ptr[0];
ptr = strtok(0, ":");
(*sub).statSec = ptr[0];
ptr = strtok(0, ":");
(*sub).endHour = ptr[0];
ptr = strtok(0, ":");
(*sub).endMin = ptr[0];
ptr = strtok(0, ":");
(*sub).endSec = ptr[0];
}
printf("\n");
strcpy((*sub).sub, ptr);
}
fclose(textFile);

}
long converMil(long hour,long min, long sec){
return (hour*3600000)+(min*60000)+(sec*1000);
}
long mil2hour(long mil){
long hour;
hour=(mil/(1000*60*60));
return hour;
}
long mil2min(long mil){
long min;
min=(mil%(1000*60*60))/(1000*60);
return min;
}

long mil2sec(long mil){
long sec;
sec=(((mil%(1000*60*60))%(1000*60))/1000);
return sec;
}
void changeTime(long time,char * srtFile){
FILE * f1;
long stime;
long etime;
struct subStruct * sub;
f1 = fopen(srtFile,"wa");
(*sub).order;
stime=((converMil((*sub).statHour,(*sub).statMin,(*sub).statSec)) +time);
// etime=((converMil((*sub).endHour,(*sub).endMin,(*sub).endSec) +time));
(*sub).statHour = mil2hour(stime);
(*sub).statMin = mil2min(stime);
(*sub).statSec = mil2sec(stime);
(*sub).endHour = mil2hour(etime);
(*sub).endMin = mil2min(etime);
(*sub).endSec = mil2sec(etime);
(*sub).sub;
fwrite((struct subStruct*)sub,sizeof(struct subStruct),1,f1);
fclose(f1);
}

wat i am doing now is:
i store structure into the .srt file then
i read the .srt file to get the times then change into millisecond
after that, i add the 3000millsecond with the time that i just change into millisecond
then, i changed back the time format hour:min:second, millisecond
then save the changed time into the original .srt file

my problem is when i try to save the changed times into the original .srt file
the format is changed.
can any1 help me to fix the problem.
thanks for your time
Topic archived. No new replies allowed.