Thread: Problem with a recursive function

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    1

    Question 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. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    9
    tell me wht the problem actually is!

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    28
    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.
    curiousity killed the cat, but it
    makes for one hell of a programmer.

    Alien.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. Recursive function problem
    By trnd in forum C Programming
    Replies: 5
    Last Post: 01-30-2009, 12:36 AM
  3. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  5. recursive function problem
    By jk81 in forum C Programming
    Replies: 2
    Last Post: 10-25-2002, 06:02 AM