Code:
/
i = 0; k = 0;
for (j = 0; j < num ; )
{
printf("j %d %d %d %s %s\n",j, i, k, etf1[i].date,etf2[k].date);
while((comp = strncmp(etf1[i].date,etf2[k].date,8)!= 0))
{
l = 0; m = 0;
printf("comp %d\n", comp);
if (comp > 0)
{ //printf("here2\n");
m++;
i++;
printf("2 %d %d %d %s %s\n",j, i, k, etf1[i].date,etf2[k].date);
}
elseif (comp < 0)
{
l++;
k++;
printf("1 %d %d %d %s %s\n",j, i, k, etf1[i].date,etf2[k].date);
}
}
if (comp == 0)
{
i++;
k++;
j++;
}
elseif (l > m)
{
j = j + m;
}
else
{
j = j + l;
}
}
/
I have two list of dates etf1[*].date and etf2[*].date The lists do not have the same dates and the code is meant to find the matching dates. You can see when the date in the first date column begins to lags, the code goes to the next date. However when date column two lags, the value of strncmp () doesn't become negative. What gives? stupid error? Not understanding how strncmp works? Confused.
Code:
next date 20050609 20050609
next date 20050610 20050610
next date 20050613 20050613
next date 20050614 20050615
comp 1
adjustment 20050615 20050615
next date 20050616 20050616
next date 20050617 20050617
next date 20050620 20050620
next date 20050621 20050623
comp 1
adjustment 20050622 20050623
comp 1
adjustment 20050623 20050623
next date 20050624 20050624
next date 20050627 20050627
next date 20050628 20050628
next date 20050630 20050629
comp 1
adjustment 20050701 20050629
comp 1
adjustment 20050705 20050629
comp 1
adjustment 20050706 20050629
Last edited by a moderator: