# Thread: Problem with a recursive function

1. ## Problem with a recursive function

Hi !

I really need help ... I don't understand why my function does'nt work ...

I make a program which sort a file with a maximum of 4 keys.

And then I have made a function which make the first sort and if there are more than one key, continue and call itself.

But it does'nt work ... Could you help me please ?

Here the code of the function :

void tribul (char ** plist,int nbdep[4],int nblong[4],int nbel,char ** argv,int nbcle,int nocle,int y,int b)
{
int d,f,m,n,o,comp,snbel=1,z;

d = nbdep[y];
f = nblong[y];

for (m=nbel-1;m>0;m--)
{
for (n=b;n<(m+b);n++)
{
comp = morceau(strlen(plist[n]),plist[n],strlen(plist[n+1]),plist[n+1],d,f);

if (argv[nocle][1] == 'C' && comp > 0)
{
swap (plist,n);
}
if (argv[nocle][1] == 'D' && comp < 0)
{
swap (plist,n);
}
}
}

o=0;

for (m=nbel-1;m>0;m--)
{
comp = morceau(strlen(plist[o]),plist[o],strlen(plist[o+1]),plist[o+1],d,f);

if (comp == 0)
{
snbel++;
}
else
{
if (snbel > 1 && nbcle >= nocle+1)
{
z = o-snbel+1;
nocle++;
y++;
tribul (plist,nbdep,nblong,snbel,argv,nbcle,nocle,y,z);
snbel = 1;
}
}
o++;
}
}

Thank you very much in advance ...

Fofone

2. tell me wht the problem actually is!

3. not exactly sure what ur trying to do but try to trim that function down to its bare necessities and see if the recursion works,

then add the rest of the code.

recursion can be a royal b**** to debug, especially if ur new at it.

and a brief explanation of what the problem ur getting is, would help.