EmbLogic's Blog

E14 need help.. to Siddarth Sir

facing problem with compression…plz help

#include<stdio.h>
#include<string.h>
#define max_arr 255

//___________________________________________________ vars
char master_array[max_arr];
char str[]=”she selles sea shells at the sea shore”;
char compressed_byte[max_arr],final_array[max_arr],expanded_byte[max_arr];
int count=0;

//___________________________________________________ fun
char merge_bytes(char,char);
int get_char_index(char);
char int_to_char(int);
int compress();

//___________________________________________________main

int main()
{
int i=0,len;
len=strlen(str);
for(i=0;i<=len;i++)
{
if(!find_in_array(str[i]))
put_in_array(str[i]);

}
return 0;
}

//___________________________________________________ fun def

int compress()

{
int i,len,j;
len=strlen(str);
for(i=0,j=0;i<=len;i=i+2,j++)
{
compressed_byte[j]=merge_bytes(int_to_char(get_char_index(str[i])),int_to_char(get_char_index(str[i+1])));
return 0;
}
compressed_byte[j]=”;
return 0;
clear_empty_bytes();
}

char int_to_char(int num)
{
char ch;
return ch=(char)num;
}

int get_char_index(char ch)
{
int i;
for(i=0;i<=count;i++)
{
if(master_array[i]==ch)
return i;
}
}

char merge_bytes(char upper_nibble,char lower_nibble)
{
char final_byte;
final_byte=upper_nibble<<4;
final_byte|lower_nibble;
return final_byte;
}

int put_in_array(char ch)

{
master_array[count]=ch;
count++;
return 1;
}

int find_in_array(char ch)
{
int i=0;
for(i=0;i<=count;i++)
{
if(ch==master_array[i])
return 1;
}
return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>