bit stuffing sending and receiving
#include<stdio.h>
int sender(char str[],char ptr[],char dest[])
{
int i,j=0,k=0,c=0,count=0;
for(k=0;k<8;k++)
{
if(k==0||k==7)
dest[k]='0';
else
dest[k]='1';
}
for(i=0;str[i]!='\0';i++)
{
count++;
if(str[i]==ptr[j])
{
dest[k]=str[i];
c++;
k++;
if(c==5)
{
dest[k]='0';
k++;
j=0;
c=0;
}
}
else
{
dest[k]=str[i];
k++;
j=0;
c=0;
if(str[i]=ptr[j])
{
c++;
j++;
}
}
}
j=0;
while(ptr[j]!='\0')
{
dest[k]=ptr[j];
k++;
j++;
}
dest[k]='1';
dest[k+1]='0';
dest[k+2]='\0';
printf("\nString send from sender side \n%s",dest);
return count;
}
/*int receiver(char result[],char dest[])
{
int i=0,j=0,k=0,count;
for(k=8;dest[k]<a+8;k++)
{
result[i]==dest[k];
i++;
}
printf("strring receive from receiver is %s",result);
}*/
void main()
{
char ptr[10]={'0','1','1','1','1','1','\0'};
char dest[100];
char str[100];
char result[100];
char flag[10]={'0','1','1','1','1','1','1','0','\0'};
int i,j,a;
printf("Enter the string:- \n");
scanf("%s",str);
sender(str,ptr,dest);
//printf("\nstrring receive from receiver is %s",str);
}
Comments
Post a Comment