2009-11-26, 04:52 PM
ok, believe i have everything working to an extent, only problem seems to be that subsequence has an issue with duplicate letters as well, as iii and icc get returned as subsequences of peice (i used the example in the assignment, dont ask me why iii and icc are in the dictionary.txt file)
can anyone point out what i can change to fix that? Because im close enough now that part of me just wants to turn the thing in and have done.
can anyone point out what i can change to fix that? Because im close enough now that part of me just wants to turn the thing in and have done.
Code:
int subsequence(char shortstr[], char longstr[])
{
int i, j;
j=0;
for (i = 0; longstr[i]; i++){
while (shortstr[j]) {
if (longstr[i] != shortstr[j])
break;
else
j++;
}
}
if (shortstr[j] == '\0')
return 1;
else
return 0;
}
