PacoLoko 0 Newbie Poster

ok, i'm trying to do a simple DES program...
and i need help to do the permutation
that's my first simple code,
i need to chance the order of bits of 3 chars
i have the table
table={11,15,3,7,12,5,8,17,24,21,4,1,6,9,2,13,10,14,23,18,20,19,22,16} //24 bits
i have idea how to do about 8 bits[a simple char]...but i need to do with 3 chars[24 bits]
the table is not fix, the permutation have to work if i change the table
can someone help me?

# include <stdio.h>



char getbit(unsigned char n, int posic) 

{

    n=n>>(posic-1); 

	n= n & 0x01; 

                

	return n;
}





setbit(unsigned char *n, int pos, int bit)

{

     if (bit == 0)

        *n = *n & ~ (1 << pos); 

     else if (bit == 1)

        *n = *n | (1 << pos); 

} 
 


permutation()
{
    table={11,15,3,7,12,5,8,17,24,21,4,1,6,9,2,13,10,14,23,18,20,19,22,16} //24 bits


}       


main()

{

      unsigned char a;

      unsigned char b;
      unsigned char c;
   
      

      a=64; //sets the value to a, 
      b=124;
      c=99;

      setbit(&a, 3, 1); //this function sets 1 the third bit of char a;
      permutation();
}