Hi!
Today we saw the information about lists. We have an assignment about CGI.
That's all going well, but we're stuck at the insertion sorft of linked
lists
--
void voeg_in_lijst(const char* padname, int matches, match *& bestanden) {
match *hulp;
hulp=new match;
strcpy(hulp->url, padname);
hulp->aantal=matches;
if(bestanden==0 || bestanden->aantal<matches){
if (bestanden==0){
bestanden=hulp;
bestanden->vlg=0;
}
else
{
match *temp;
temp=bestanden;
bestanden=hulp;
bestanden->vlg=temp;
}
}
else{
match *schuiver=bestanden->vlg;
while(schuiver!=0 && schuiver->aantal>hulp->aantal){
schuiver=schuiver->vlg;
}
if (schuiver!=0){ // doe insertion
match *extra=schuiver->vlg;
schuiver->vlg=hulp;
hulp->vlg=extra;
}
}
}
--
voeg_in_lijst is dutch for add_in_list. padname is the name of "file" we
need to add in the list, matches is the frequency a word comes forward en
match *bestanden is a list.
So what do we do ...
We check all the lists untill we found an element that is smaller then our
matches.
And then we add in the list.
But that doesn't work ... We have errors. Something about the memory I
assume.
The problem is, we (3 persons) are searching for the fault for 2 days and
can't find the fault. And it must be something stupid!
But I think it's difficult to help, as I can't explain/translate the
assignment ... maybe you can view the whole cpp file:
http://members.lycos.co.uk/jochus/in...oj/CGI/cgi.cpp
-> header:
http://members.lycos.co.uk/jochus/in...Proj/CGI/cgi.h