Networking >> Bit Stuffing Simulation Program
In bit stuffing processing, we add 0 after five consecutive 1's in databits.
#include<stdio.h>
int main()
{
int i=0,count=0;
char databits[80];
printf("Enter Data Bits: ");
scanf("%s",databits);
printf("Data Bits Before Bit Stuffing:%s",databits);
printf("\nData Bits After Bit stuffing :");
for(i=0; i<strlen(databits); i++)
{
if(databits[i]=='1')
count++;
else
count=0;
printf("%c",databits[i]);
if(count==5)
{
printf("0");
count=0;
}
}
return 0;
}
Output of the Program:
Enter Data Bits: 101111111000
Data Bits Before Bit Stuffing:101111111000
Data Bits After Bit stuffing :1011111011000
No comments:
Post a Comment