Folks, this is my code for LZ77. I can't seem to find what the problem is. Can anyone help me out here? Any programmers at sajha? Has anyone had to code LZ77 before? I tell ya, it's a pain in the butt! Hers is my compression code: I still have to work on my decompression routine. Thanks for any help guys! Peace! -LoGiN ************************************************************* #include #include #include /**************************************************************/ int SW, swb, LA, lab, minsearch, offset, length, inamount; int lastrun, lastbits, alreadyin; FILE *fin,*fout; char *swbegin, *swend, *labegin, *bigbuf,*endfile; int curroffset = 0; unsigned char currbyte; int pow(int x, int z) { int y; int w = 1; for(y=1;y 8){ templen = 8 - curroffset; ByteIntoBits(inchar, start, templen); ByteIntoBits(inchar, start + templen, len - templen); return; } mask = (unsigned char)(pow(2, len) - 1); if ((j = 8-start-len) > 0) mask start) mask >>= curroffset - start; currbyte |= mask; curroffset += len; if (curroffset > 7) { curroffset -= 8; fwrite(&currbyte, 1, 1, fout); currbyte = 0; }} /***************************************************************/ int Findbiggest() { while(length>minsearch){ while(swbeginminsearch){ if(Findbiggest()){ Code();} else { Single();} swbegin = swend - SW; length=endfile-swend-1; } } alreadyin=swend-labegin; for(a=0;a<SW+LA-alreadyin;a++)*(bigbuf+a)=*(swend-SW+a); swend=bigbuf+SW; } /******************************************************************/ int main(){ char buf1[100]; int i = 8; alreadyin = lastrun = lastbits = 0; swb = lab = 3; printf("\n\nPlease enter the size of your sliding window: "); scanf("%d", &SW); printf("\n\nPlease enter the size of the look-ahead buffer: "); scanf("%d", &LA); while(i<SW){i*=2; swb++;} SW=i; i=8; while(i<LA){i*=2; lab++;} LA=i; i=0; minsearch = (9+swb+lab)/9; printf("\nFor reasons above your level of intelligence you were"); printf("\ngiven a SW size of %d and LA buffer of %d\n",SW,LA); bigbuf=(char *)malloc(2*SW + LA); for(i=0;i<SW;i++){*(bigbuf+i)=(unsigned char)0;} printf("\n\nWhat file do you want to compress? "); scanf("%s",buf1); fin = fopen(buf1,"rb"); printf("\n\nWhere do you want to compress into? "); scanf("%s",buf1); fout =fopen(buf1, "wb"); if(!fin || !fout){puts("Could not open file - exit!!!"); exit(1);} /******************************************************************/