Bit stuffing with flag c++ Language
#include<bits/stdc++.h>
using namespace std;
int main()
{
char stuf[50],so[50],range[50];
int i,j,count;
cout<<"enter the data :";
cin>>so;
cout<<"enter the flag data :";
cin>>range;
count=0,j=0;
for(i=0;i<strlen(so);i++)
{
if(so[i]=='1')
{
count++;
}
else
{
count=0;
}
stuf[j]=so[i];
j++;
if(count==5 && so[i+1]=='1')
{
stuf[j]='0';
j++;
count=0;
}
}
stuf[j]='\0';
cout<<"after bit stuffing : " <<range<<stuf<<range<<endl;
return 0;
}
Output:
Bit stuffing with flag c++ Language
Reviewed by Saroar Zahan Sojib
on
February 22, 2019
Rating:
No comments: