To
write a C program to perform the BIT
STUFFING using linux enviroinment.
Step1: Start the program.
Step2: Get the messages and check the message for five repeated “1” value.
Step3: If it is true then add “0” as next value.
Step4: Print the sending messages one by one.
Step5: Stop the program.
Source code
// Comment #include<stdio.h> #include<string.h> main() { char b[30]={0,0},c[30]={0,0},a[40]="01111110",e[40]="01111110"; int i,j=0,cnt=0,n; printf("enter the string"); scanf("%s",b); n=strlen(b); for(i=0;i<n;i++) { c[j]=b[i]; if(b[i]='1') cnt++; else cnt=0; if(cnt==5) { c[++j]='0'; cnt=0; } j++; } printf("after bit stuffing \n"); strcat(a,c); strcat(a,e); printf("%s",a); }
Output
[t03it @localhostt03it ]$ cc bitstuff.c
[t03it @localhostt03it ]$./a.out
enter
the string 111111
after
bit stuffing
01111110111110101111110
No comments:
Post a comment