Huh?
Code:
/
char * find_start_date( int i, int j, char **etf_list)
{
char *start_date1,*start_date2, *full_name, *line;
FILE *etf1,*etf2;
int comp, k;
start_date1 = (char *)calloc(14, sizeof(char));
start_date2 = (char *)calloc(14, sizeof(char));
line = (char *)calloc(100, sizeof(char));
full_name = (char *)calloc(100, sizeof(char));
strcpy(full_name,home);
strcat(full_name,etf_list[i]);
// printf("%s\n",full_name);
if ( (etf1 = fopen(full_name,"r") ) == NULL)
printf("did not open %s\n",full_name);
strcpy(full_name,home);
strcat(full_name,etf_list[j]);
if ((etf2 = fopen(full_name,"r")) == NULL)
printf("did not open %s\n",full_name);
// read first line
fgets(line,100,etf1);
start_date1 = get_date(etf1);
fgets(line,100,etf2);
start_date2 = get_date(etf2);
fclose(etf1);
fclose(etf2);
if ((comp = strcmp(start_date1,start_date2)) == 0)
return (start_date1);//return (etf_list[i]);
elseif (comp > 0)
return ("0");
else
return("0");
};
char* get_date(FILE *fp)
{
char *start_date, *line;
start_date = (char *)calloc(20, sizeof(char));
line = (char *)calloc(100, sizeof(char));
fgets(line,100,fp);
strtok(line,",");
strtok(NULL,",");
strcpy(start_date,strtok(NULL,","));
return(start_date);
};
/[code]