i need to loop through each song and compare it with the other song, if its the same, then i need to check if the word positions are one appart.
Theres probably some logic errors in there, but i just cant work out what it is. please help me out
int wordQuery(Position result,Position result2)
{
struct Song *song,*song2;
struct WordPosition *position, *position2;
if (result != NULL && result2 !=NULL)
{
song = result->firstSong;
song2 = result2->firstSong;
fprintf(stderr,"Song\n");
fprintf(stderr,"----\n");
while (song != NULL)
{
while (song2 != NULL)
{
if(song2->Number == song->Number)
{
position = song->firstPosition;
while(position != NULL)
{
position2 = song2->firstPosition;
while(position2!=NULL)
{
if((position->Number+1)==position2->Number);
{
printf("Song Number: %d Position: %d\n",song->Number,position->Number);
break;
}
position2=position2->nextPosition;
}
position=position->nextPosition;
}
}
else
song2=song2->nextSong;
}
song = song->nextSong;
song2 = result2->firstSong;
}
fprintf(stderr,"\n");
}
return EXIT_SUCCESS;
}

New Topic/Question
Reply




MultiQuote




|