Monday , December 18 2017
Home / C / C Program for Bit Stuffing

C Program for Bit Stuffing

Bit Stuffing: In bit stuffing following rules hold:- 

  1. To the given bits add the string 01111110 to both the starting and the end of the string
  2. To add 0 to each set of 5 one’s i.e. after every five consecutive 1’s appear a zero
#include "stdio.h"
#include "conio.h"
int main()
{
int i=0,count=0;
char a[100];
printf("enter the bits : ");
scanf("%s",a);

printf("\nAfter bit stuffing \n");
printf("01111110");

for(i=0;a[i]; i++)
{
    if(a[i]=='1')
        count++;
    else
        count=0;
printf("%c",a[i]);
if(count==5)
    {
        printf("0");
        count=0;
    }
}
printf("01111110");
getch();
return 1;
}

 

OUTPUT:

bit stuffing

 

Tags: Write a C program for bit stuffing, bit-stuffing

Also See:   C Program to make a Calculator - Source Code

Check Also

How to Solve Linear Equation in One Variable In C Programming?

C Program to Solve any Linear Equation in One Variable Find complete C program to ...

7 comments

  1. program is not correctly executing

  2. cout1 is not initilized

  3. awesome code…. and its soooooooooooo simple and short….. thank you

  4. very useful….
    but the coding for destuffing the bits is not found..

Leave a Reply

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